Search code examples
fluttervisual-studio-code

I Does Not Run my flutter project in VSCode IDE


In the meantime, I was able to my flutter projects well with VSCode IDE.

However, due to circumstances, I couldn't work on Flutter for a few months.

Then I came back and ran my project that was previously executed in VSCode, but it was not running. Even if I press the "Start without debugging" button in the main.dart file and run it, the project does not run after only very short briefly showing the message "Starting debug session..." at the bottom of VSCode.

Even if you create a completely new counter default project and run it with no modification, the same message is poped up at the right bottom of VSCode and then disappears, and the project does not run.

Worse still, I don't see any execution error messages in the problems window, in the output window, in the debug console window, and in the terminal window. It's clean.

But if I run the command "flutter run" in the terminal window of VSCode, the project is running normally. I also set the 'Path' environment variable for Windows to 'flutter/bin' normally. My internet speed is very fast.

I remember that in the past, when I pressed the "Start without debugging" button in the main.dart file, the project ran.

Of course, if I run the command "flutter run" in the terminal window, the project will be executed, but it will be very cumbersome.

Is there a way to run the project by pressing the "Start without debugging" button on VSCode?

I have 1 regular Desktop Windows PC and 1 Windows laptop and both are showing the same phenomenon.

The flutter version of a regular PC is

Flutter 3.22.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 761747bfc5 (8 weeks ago) • 2024-06-05 22:15:13 +0200
Engine • revision edd8546116
Tools • Dart 3.4.3 • DevTools 2.34.3.

The flutter version of the laptop is

Flutter 3.16.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 78666c8dc5 (7 months ago) • 2023-12-19 16:14:14 -0800
Engine • revision 3f3e560236
Tools • Dart 3.2.3 • DevTools 2.28.4.

My "settings.json" of VSCode:

{
   "workbench.startupEditor": "none",
   "github.gitAuthentication": false,
   "editor.mouseWheelZoom": true,
   "editor.wordWrapColumn": 90,
   "editor.formatOnSave": true,
   "editor.fontFamily": "\"JetBrains Mono\", \"Consolas\", \"Courier New\", monospace",
   "editor.fontLigatures": "calt",
   // "editor.fontSize": 11.5, // editor font 크기(JetBrains mono)
   "editor.fontSize": 12.2, // editor font 크기(JetBrains mono)
   "editor.tabSize": 3,
   "editor.guides.bracketPairs": true,
   "editor.suggestSelection": "first",
   "editor.bracketPairColorization.enabled": true, // 괄호별 색상 적용 
   "editor.inlineSuggest.enabled": true,
   "editor.stickyScroll.enabled": true,
   "editor.linkedEditing": true,
   "editor.codeActionsOnSave": {
      "source.fixAll": "explicit"
   },
   "editor.language.colorizedBracketPairs": [],
   // "editor.renameOnType": true,
   "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
   "files.autoGuessEncoding": true,
   "workbench.editor.highlightModifiedTabs": true, // 파일 수정시 탭 색상 변경
   "workbench.colorCustomizations": {
      "tab.activeBackground": "#F0FFFF"
      // "tab.activeBackground": "#FAFAD2"
   },
   "[dart]": {
      "editor.formatOnSave": true,
      "editor.formatOnType": true,
      "editor.rulers": [
         90
      ],
      "editor.selectionHighlight": true,
      "editor.suggest.snippetsPreventQuickSuggestions": false,
      "editor.suggestSelection": "first",
      "editor.tabCompletion": "onlySnippets",
      "editor.wordBasedSuggestions": "off",
   },
   "dart.warnWhenEditingFilesOutsideWorkspace": false,
   "dart.renameFilesWithClasses": "prompt",
   "dart.previewFlutterUiGuides": true,
   "dart.previewFlutterUiGuidesCustomTracking": true,
   "dart.openDevTools": "flutter",
   "dart-data-class-generator.useEquatable": true,
   "workbench.colorTheme": "Default Light Modern",
   "redhat.telemetry.enabled": true,
   "vs-kubernetes": {
      "vs-kubernetes.minikube-show-information-expiration": "2023-12-25T04:51:22.688Z"
   },
   "dart.debugExternalPackageLibraries": true,
   "dart.debugSdkLibraries": false,
   "dart.flutterHotReloadOnSave": "allIfDirty",
   "git.openRepositoryInParentFolders": "never",
   "dart.shareDevToolsWithFlutter": true,
} 

Where should I look to solve this problem?


Solution

  • You must create launch.json file in your .vscode folder you can copy/paste this content (replace so_march by your project name)

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "so_march",
                "request": "launch",
                "type": "dart",
                "program": "lib/main.dart", 
            },
            {
                "name": "so_march (profile mode)",
                "request": "launch",
                "type": "dart",
                "flutterMode": "profile"
            },
            {
                "name": "so_march (release mode)",
                "request": "launch",
                "type": "dart",
                "flutterMode": "release"
            }
        ]
    }