在 Chrome 开发工具中调试 Javascript 时,使用保留关键字“调试器”会导致开发工具打开时出现断点。在 Dartium 中是否有用于调试 dart 代码的等价物?
从 Dart SDK 1.11.0 开始debugger,新dart:developer库中有一个函数可以通过代码触发断点。您可以使用when参数传递可选条件并提供可选消息。
import 'dart:developer';
void main() {
debugger();
print('Not reached when a debugger is attached till the execution is continued');
}
Run Code Online (Sandbox Code Playgroud)
如果编译为 JavaScript,debugger则使用关键字。