首页 > 解决方案 > 飞镖角度与调试

问题描述

我刚开始使用 dart,我已经成功地在 vs 代码中正确配置了 dart 命令行项目和颤振应用程序,并且调试按预期工作,以尝试跨平台项目但是使用 dart angular,我无法让断点工作, dart 中的文档似乎主要集中在颤振中,但是我不能在这种特定类型的 dart 项目中设置断点。这是我当前的 dart launch.json。

{ 
"version": "0.2.0",
  "configurations": [
    {
      "name": "Dart",
      "program": "web/main.dart",
      "request": "launch",
      "type": "dart"
    }
  ]
}

我正在使用飞镖版本 2.9.1。

标签: dartvisual-studio-codeangular-dart

解决方案


however i cant breakpoint within just this specific type of dart project

Right now there is a race condition in non-Flutter web debugging, where the breakpoints are not set up before the app starts, so any breakpoints in startup code are missed.

There's an open issue at https://github.com/dart-lang/webdev/issues/830 but as a workaround you could try inserting a delay (eg. await Future.delayed(const Duration(seconds: 1)) or calling the debugger function at the top of your main function if you need to break in startup code).


推荐阅读