flutterdartvisual-studio-codefvm

Use fvm to change flutter version in vscode, but the flutter version not work?


I added fvm to my project and set it up like this. Now I can run all the commands for example fvm use x.x.x or fvm flutter pub get. Everything works.

BUT when running the application through VSCode directly (Play button or shortcut) it always uses my latest install SDK version. Why is it not starting with the current flutter version ?

This is my settings.json:

  {
  "dart.flutterSdkPaths": [
    "/Users/usr/fvm/versions"
  ],
    // Remove .fvm files from search
    "search.exclude": {
      "**/.fvm": true
    },
    // Remove from file watching
    "files.watcherExclude": {
      "**/.fvm": true
    }
  }

What am I missing here? How do I configure fvm to work correctly with VSCode?


Solution

  • I'm assuming you have the .fvm folder set up properly? ie. It contains the symlink flutter_sdk (which points to the currently selected SDK) and the fvm_config.json.

    In your settings.json file, you also need to set the location of the SDK itself:

    "dart.flutterSdkPath": ".fvm/flutter_sdk",
    

    Which will point to the same symlink.