Flutter ships a new stable release every few months, and each one can change lints, generated code, Gradle and CocoaPods requirements, or widget behaviour. Agencies and product teams usually maintain several apps at once, and upgrading all of them the same week is rarely possible. Without a version manager, one global flutter on PATH means the act of upgrading for one app silently changes every other app you open.

We maintain five Flutter apps, two of them held on an older stable while a payment SDK catches up. This guide covers how we use FVM (Flutter Version Management) so every app, IDE and CI job builds with the SDK that app expects.

What FVM does

FVM keeps a cache of Flutter SDK versions and links one of them into each project. The project records the choice in a small config file that you commit, so the version is part of the repository like pubspec.lock.

Key pieces in FVM 3:

Item

Purpose

Commit it?

.fvmrc

JSON with the pinned version and project options

Yes

.fvm/

Local link to the cached SDK, plus metadata

No, add to .gitignore

FVM cache

Downloaded SDKs, shared across projects

Not in the repo

Install FVM using one of the methods in its docs (Homebrew on macOS, a standalone install script, Chocolatey on Windows, or dart pub global activate fvm), then check it:

fvm --version
fvm doctor

Pinning a project

From the project root:

fvm releases            # stable, beta and master versions available
fvm install 3.27.1
fvm use 3.27.1

fvm use writes .fvmrc:

{
  "flutter": "3.27.1"
}

It also creates .fvm/ with a link to the cached SDK and offers to add .fvm/ to .gitignore. Accept that; the link is machine-specific.

From now on, run Flutter and Dart through FVM in that project:

fvm flutter --version
fvm flutter pub get
fvm dart run build_runner build --delete-conflicting-outputs

Typing fvm before every command is tedious. Many developers alias flutter to fvm flutter, which works because FVM resolves the version from the nearest .fvmrc. Outside a pinned project, fvm flutter falls back to the global version set with fvm global, and fails clearly if none is set.

Pinning a channel instead of a version (fvm use stable) is possible but defeats the purpose for apps, since stable moves. Pin exact versions for anything that ships to a store.

Flavors for staged upgrades

When we upgrade an app, we like to keep the old SDK one command away. FVM supports named flavors inside .fvmrc:

{
  "flutter": "3.27.1",
  "flavors": {
    "current": "3.27.1",
    "next": "3.29.3"
  }
}

fvm use next switches the project to the next flavor's version for an upgrade branch, and fvm use current switches back. On the upgrade branch we commit the .fvmrc change together with the code fixes, so reviewers see the SDK bump and its consequences in one pull request. fvm spawn 3.29.3 test runs a single command on another version without switching the project, which is useful for a quick "does it still build" check.

Pointing the IDE at the pinned SDK

Most "FVM is not working" reports we see are really the IDE using a different SDK from the terminal.

VS Code

The Dart extension reads dart.flutterSdkPath. FVM can write this into .vscode/settings.json for you when you run fvm use (the updateVscodeSettings option in .fvmrc, on by default). The result points at the project link, for example:

{
  "dart.flutterSdkPath": ".fvm/versions/3.27.1"
}

If your team commits .vscode/settings.json, keep this key in it so everyone uses the link. If you do not commit editor settings, have each person run fvm use once after cloning. Reload the window afterwards; the Dart extension caches the SDK at startup.

Android Studio and IntelliJ

Open Settings, then Languages and Frameworks, then Flutter, and set the Flutter SDK path to the project's .fvm/flutter_sdk link. Also check Languages and Frameworks, then Dart, which keeps its own SDK path. After changing them, run Invalidate Caches if the editor keeps showing analysis errors from the old SDK.

Because Android Studio points at the project link, and FVM rewrites the VS Code setting each time you run fvm use, switching versions updates both editors. Restart the analysis server after switching.

Pinning in CI

CI must use the same version as .fvmrc, and should not download a 1 GB SDK on every run.

Two approaches work:

Use FVM in CI. Install it, then let it read .fvmrc:

- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
- run: dart pub global activate fvm
- run: fvm install
- run: fvm flutter pub get
- run: fvm flutter test

Cache the FVM cache directory between runs, keyed on the content of .fvmrc, so a cache hit skips the download entirely.

Use a Flutter setup action and read the version from the repo. For example, extract the version with jq -r .flutter .fvmrc in an earlier step and pass it to the action's version input. This avoids installing FVM in CI but adds a small script. Either way, the version lives in exactly one file.

We add a lightweight check job that fails if anyone hard-codes a Flutter version elsewhere:

want=$(jq -r .flutter .fvmrc)
have=$(fvm flutter --version --machine | jq -r .frameworkVersion)
[ "$want" = "$have" ] || { echo "CI Flutter $have, .fvmrc wants $want"; exit 1; }

Codemagic, Bitrise and similar services also expose a Flutter version setting; set it to the same value or call FVM from a script step, and add the check above.

Onboarding a new teammate

Our README for each app has this short block, and it is all most people need:

# one-time per machine
fvm --version || echo "install FVM first, see docs link below"

# per project
git clone <repo> && cd <repo>
fvm install          # reads .fvmrc, downloads if missing
fvm use              # creates .fvm link and IDE settings
fvm flutter doctor
fvm flutter pub get

Two more rules prevent most surprises:

  • Do not run flutter upgrade inside a pinned project. It upgrades the cached SDK in place for every project using it. Change versions with fvm use <version> instead.

  • Keep pubspec.yaml's SDK constraints honest. If the app needs Dart 3.6 features, say so in environment: sdk:. A teammate with the wrong SDK then gets an immediate solver error instead of strange compile failures.

Common mistakes

Mistake

Why it hurts

Do this instead

Committing .fvm/

Machine-specific link breaks on other laptops

Commit only .fvmrc, ignore .fvm/

IDE pointed at a global SDK

Analyzer and builds use different versions

Point the IDE at the project link

flutter upgrade in a pinned project

Changes the shared cached SDK

fvm use <new version>

Pinning stable

Version changes without a commit

Pin an exact version

CI with its own hard-coded version

Drifts from .fvmrc

Read .fvmrc in CI and verify

Key takeaways

  • FVM pins Flutter per project through a committed .fvmrc; the .fvm/ link stays local.

  • Point VS Code and Android Studio at the project link, not a global SDK.

  • Use flavors or fvm spawn to test the next SDK before switching.

  • Make CI read the same file and cache the SDK.

  • Never run flutter upgrade inside a pinned project.

References