Search code examples
fluttervisual-studio-codeflutter-dependenciesbreakpointsflutter-test

VS Code non-test breakpoints are set to inactive when running Flutter tests


When debugging a Flutter unit or widget test, breakpoints set in the main source (under lib/) are set to inactive and the execution doesn't pause when that line of code is executed. The only way to debug that code is to set a breakpoint in the test being executed and manually step into the main source code. How can I configure VS Code so that I can set a breakpoint anywhere?


Solution

  • This was bugging me for a few weeks before I stumbled across a solution when adding a breakpoint to source code in an external package. VS Code prompted me whether I want to debug just my source code or all code. After selecting "Debug all code" I was suddenly able to hit breakpoints set in my lib folder when running tests.

    This setting can be toggled by adding the following lines to settings.json:

    "dart.debugExternalPackageLibraries": true,
    "dart.debugSdkLibraries": true
    

    https://dartcode.org/releases/v0-14/#debug-just-my-code