Flutter version manager
Last modified on Thu 14 Mar 2024

With the help of Flutter version manager (FVM) we can use a specific vesion of Flutter for each of our projects.

There are several benefits to this approach:

Setup

One person should setup FVM in the project. If the setup is already completed, you can skip to Using FVM.

Setup FVM in project

Follow the official instructions to setup FVM and configure the .fvmrc file.

Only commit the .fvmrc file. The .fvm/ folder should be added to .gitignore:

# FVM Version Cache
.fvm/

Setup FVM on Bitrise

Use the Extract FVM Flutter version Bitrise step to obtain the Flutter version. In the Flutter Install step, set Flutter SDK git repository version to $FVM_FLUTTER_VERSION.

Using FVM

When calling Flutter from the command line, use the fvm prefix:

# instead of writing
flutter pub run build_runner

# use the fvm prefix
fvm flutter pub run build_runner

When using an IDE (Android Studio), change the Flutter SDK path to the one provided by FVM:

Android Studio > Settings... > Language & Frameworks > Flutter

Change the Flutter SDK path to .../project-name/.fvm/flutter_sdk.

Now all your run, debug and other tools will use the Flutter version defined in the .fvmrc file.

IMPORTANT: the IDE setup is per-project, meaning it will have to be done for each project that uses FVM.