Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

VS Code shows no Run and Debug option for a Flutter project

ErrorNo Run and Debug button or Start Debugging entry for a Flutter project

Short 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.

  • Applies to VS Code current stable, Flutter extension (Dart-Code.flutter), Flutter 3.3x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 -v
  2. 2Match what you see, then jump to its fix

    1. 1The command palette shows no Flutter: commandsThe Flutter extension is not installedFix
    2. 2No Flutter version or device in the status barThe folder with pubspec.yaml is not a workspace folderFix
    3. 3The 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

What does the error look like?

  • No Run and Debug button or Start Debugging entry for a Flutter project
  • Run and Debug panel only shows a 'create a launch.json file' link
  • No 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 doctor

2Fix

Install the Flutter extension, then reload the window.

# VS Code > Extensions > search "Flutter" (Dart-Code.flutter) > Install, then reload the window

3Verify

Flutter commands appear in the command palette, and the status bar shows a Flutter version once a project is open.

flutter doctor

Confirmed by docs.flutter.dev

Did this fix it?

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.yaml

2Fix

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 doctor

3Verify

The status bar shows the Flutter version and a device name, and Run > Start Debugging (F5) starts the app.

flutter doctor

Confirmed by docs.flutter.dev

Did this fix it?

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/*.dart

2Fix

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.json

Confirmed by dartcode.org

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.