Skip to content
DeveloperMemos

Using Different Versions of Flutter Simultaneously with FVM

Flutter, Flutter Tips, Stable, FVM1 min read

One thing that Flutter lacks out of the box is the ability to easily switch between versions. I wrote an explanation in another post about downgrading, and that is all well and good - but what if you have two projects and you want to keep Project 1 on Version A and Project 2 on Version B? If you just used the flutter command line tool for this you'd be upgrading and downgrading whenever you switch between projects and that could get pretty tedious.

That's why I'm writing a post today to talk about a tool called FVM, which is an acronym for 'Flutter Version Management'. To put it simply, this is a tool that allows you to install multiple versions of Flutter and switch between them on the fly - or even pin a specific project to a specific version. If you've ever used something like nvm before you'll probably be familiar with this concept.

Installing

First of all, you can install fvm with the following command(assuming you have Dart or Flutter already installed):

1pub global activate fvm

Installing Flutter versions

Once it has been installed you can install specific version of Flutter like this:

1fvm install <version>

So if you were going to install version 1.20.4 you'd do it like this:

1fvm install 1.20.4

You can browse Flutter version tags here.

Pin a project to a specific Flutter version

If you want to pin your project to a specific version of Flutter you installed with FVM you do it like this(from the root of your project's folder):

1fvm use <version>

This command will create a .fvm directory in your project and copy the version you specified into a directory called flutter_sdk.

A small warning

Like I said above it installs/copies the SDK into the .fvm/flutter_sdk directory so you'll want to make sure your IDE settings point to that directory for Flutter commands(or else it might be still using your system version of Flutter). I should probably also point out that if you're running tests from the command line or building binaries from the command line you need to make sure you preface the command with fvm. So if you were going to build for web for example.

Don't do this:

1flutter build web

Do this:

1fvm flutter build web