Dayer
Dayer

Reputation: 45

VsCode is not stopping on breakpoints - Flutter

Brand new to flutter and I'm using VSCode as my IDE. However, I can't seem to get VSCode to call any of my breakpoints I place. I've tried normal breakpoints, Expression Breakpoints. None of them are even registering.

Everywhere online says to change the launch.json which I have done as show below

"version": "0.2.0",
    "configurations": [
        {
            "name": "Flutter",
            "request": "launch",
            "type": "dart",
            "flutterMode": "debug"
        },
    ]

However it didn't do anything. I'm using android studio's emulator and sometimes chrome; works on neither. Any help is appreciated :)

Upvotes: 4

Views: 7831

Answers (3)

BlackDragonBE
BlackDragonBE

Reputation: 302

In my case it was because of the default setup of Dart debugging in VS Code. Make sure this setting at the bottom of the editor is set to "Debug my code + packages + SDK":

Debug setting at bottom of editor

If it's set to something different, click on it until it changes to "Debug my code + packages + SDK".

Upvotes: 4

Matt Mohandiss
Matt Mohandiss

Reputation: 315

I solved this issue by disabling Dart: Preview Sdk Daps in Settings. My Dart SDK was not linked to the remote repository and was outdated so this setting was not working properly. This is done with "dart.previewSdkDaps": false

{
    "workbench.startupEditor": "none",
    "editor.minimap.enabled": false,
    "debug.toolBarLocation": "docked",
    "files.autoSave": "onFocusChange",
    "dart.previewSdkDaps": false
}

Upvotes: 7

Kauli Sabino
Kauli Sabino

Reputation: 106

Well, you can use the developer package to make breakpoints

import 'dart:developer';

void someFunction(double offset) {
  debugger(when: offset > 30.0);
  // ...
}

Look it in documentation

Upvotes: 8

Related Questions