user3735816
user3735816

Reputation: 287

Trouble getting Flutter to run in debug mode in VS Code

I am able to run my Flutter project in an emulator in Android Studio. I'm trying to run that same code in debug mode (f5) in VS Code, but I get an error saying:

Set the 'program' value in your launch config (eg 'lib/main.dart') then launch again.

So I updated my launch config to the following:

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

After that update, when I try f5 I get the following error:

Your launch config references a program that does not exist. If you have problems launching, check the "program" field in your ".vscode/launch.json" file.

I DO have a main.dart file??

Any help would be greatly appreciated.

Upvotes: 3

Views: 5627

Answers (3)

Ragavi R
Ragavi R

Reputation: 79

flutter run would help, In my case first run flutter doctor , later do resolve missing configs as mentioned and then Flutter run

Upvotes: 1

user3735816
user3735816

Reputation: 287

For some reason, VS Code was using the launch config from a different project folder that was in my workspace. After removing that project, f5 worked as expected.

Upvotes: 2

EdwynZN
EdwynZN

Reputation: 5601

instead of "program": "lib/main.dart" try "flutterMode": "debug"

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

Upvotes: 9

Related Questions