VS Code shows no Run and Debug option for a Flutter project
No Run and Debug button or Start Debugging entry for a Flutter projectShort answer
VS Code offers Flutter debugging only when the Flutter extension is installed and the folder that holds pubspec.yaml is an opened workspace folder. Check the status bar for a Flutter version and a device. If your entry file is not lib/main.dart, add a launch.json with the right program.
Fix it fast
1Find out which cause you have
Run the doctor from the command palette (Ctrl/Cmd + Shift + P, then type doctor, then choose Flutter: Run Flutter Doctor). The output tab shows whether the SDK is found. The same check works in a terminal.
flutter doctor -v2Match what you see, then jump to its fix
- 1
The command palette shows no Flutter: commandsThe Flutter extension is not installedFix - 2
No Flutter version or device in the status barThe folder with pubspec.yaml is not a workspace folderFix - 3
The Run and Debug panel shows a link to create a launch.json fileThe app does not use the default entry point, so a launch.json is neededFix
- 1
What does the error look like?
No Run and Debug button or Start Debugging entry for a Flutter projectRun and Debug panel only shows a 'create a launch.json file' linkNo Flutter version or device in the VS Code status bar
Cause 1 of 3
The Flutter extension is not installed
1Check
Search the Extensions view for Flutter. The Flutter extension installs the Dart extension with it. Without them, VS Code has no Dart debug type.
flutter doctor2Fix
Install the Flutter extension, then reload the window.
# VS Code > Extensions > search "Flutter" (Dart-Code.flutter) > Install, then reload the window3Verify
Flutter commands appear in the command palette, and the status bar shows a Flutter version once a project is open.
flutter doctorConfirmed by docs.flutter.dev
Cause 2 of 3
The folder with pubspec.yaml is not a workspace folder
1Check
The extension needs the folder that contains pubspec.yaml to be inside a VS Code workspace folder. If you opened a parent folder with many projects, or a single file, the project may not be detected.
ls pubspec.yaml2Fix
Open the folder that holds pubspec.yaml with File > Open, or add it to the workspace. Then check that a device or emulator is available, since the status bar shows No Devices when none is found.
cd path/to/my_app
code .
flutter doctor3Verify
The status bar shows the Flutter version and a device name, and Run > Start Debugging (F5) starts the app.
flutter doctorConfirmed by docs.flutter.dev
Cause 3 of 3
The app does not use the default entry point, so a launch.json is needed
1Check
A launch.json is not required for the common case where the entry file is lib/main.dart. If your entry file has another name (for example lib/main_dev.dart), the extension cannot guess it.
ls lib/*.dart2Fix
Create .vscode/launch.json from the Run and Debug panel and set the program. The type must be dart.
{
"version": "0.2.0",
"configurations": [
{
"name": "Flutter dev",
"request": "launch",
"type": "dart",
"program": "lib/main_dev.dart"
}
]
}3Verify
The configuration appears in the Run and Debug drop-down. Start it with F5.
cat .vscode/launch.jsonConfirmed by dartcode.org
How do I stop it coming back?
- Open each Flutter app as its own VS Code folder rather than a parent folder of many projects.
- Run Flutter: Run Flutter Doctor after a Flutter SDK or VS Code update.
- Keep one launch.json in the repo for flavors or custom entry files so every developer gets the same entries.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
Related fixes
Mobile apps
AudioCache has no play method after updating audioplayers
The method 'play' isn't defined for the type 'AudioCache'.
Since audioplayers 1.0, AudioCache only turns asset files into local files and caches them.
2 causes, each with a fixMobile apps
Flutter Bloc throws that emit was called after the event handler completed
emit was called after an event handler completed normally.
Each on<Event> handler gets its own Emitter, and it stops working the moment the handler's returned Future completes.
2 causes, each with a fixMobile apps
analysis_options.yaml: the URI it includes can't be found
include_file_not_found
The analyzer reports include_file_not_found when the file named after include: in analysis_options.yaml does not resolve.
2 causes, each with a fixMobile apps
Dart error: the body might complete normally and return null for a non-nullable type
body_might_complete_normally
Dart found a path through your function or callback that reaches the closing brace without a return.
3 causes, each with a fixMobile apps
Dart throws ConcurrentModificationError while looping over a list
ConcurrentModificationError
Dart throws this when a collection changes size while something iterates it.
2 causes, each with a fixMobile apps
Dart cannot turn a compact timestamp like 20201101153000 into a DateTime
FormatException: Invalid date format
DateTime.parse accepts a subset of ISO 8601, and a time part must be introduced by T or a space.
2 causes, each with a fix