dartdartium

Debugging Dart in Dartium - Breakpoint Keyword?


When debugging Javascript in the Chrome Dev Tools, using the reserved keyword 'debugger' results in a break point hitting when the Dev Tools are open. Is there an equivalent for debugging dart code in Dartium?


Solution

  • Since Dart SDK 1.11.0 there is a debugger function in the new dart:developer library to trigger a breakpoint via code. You can pass an optional condition with the when parameter and provide and optional message.

    import 'dart:developer';
    
    void main() {
      debugger();
      print('Not reached when a debugger is attached till the execution is continued');
    }
    

    If compiled to JavaScript, the debugger keyword is used.