How to keep multiple versions of Flutter

Ayu
DSF Web Services Engineering
3 min readNov 16, 2020

In this article, I would like to share my experience on how to keep multiple versions of flutter like Stable or Master at once and switch them in seconds.

Illustration by Freepik Storyset

Why we need multiple version of flutter

Flutter 1.2.0 has been released and I have updated it, but some libraries didn’t work with them. So I had to keep both version: Stable and 1.17.4

It takes time to do an upgrade and downgrade every time. Then, I found a “fvm” to solve this situation. I would like to share it today.

What is “FVM”?

“FVM” is Flutter Version Management, A simple CLI to manage Flutter SDK versions per project.

FVM helps with the need for a consistent app builds by allowing to reference Flutter SDK version used on a per-project basis. It also allows you to have multiple Flutter versions installed to quickly validate and test upcoming Flutter releases with your apps, without waiting for Flutter installation every time.

This tool allows you to manage multiple channels and releases, and caches these versions locally, so you don’t have to wait for a full setup every time you want to switch versions.

Also, it allows you to grab versions by a specific release, i.e. v1.2.0 or 1.17.0-dev.3.1. In case you have projects in different Flutter SDK versions and do not want to upgrade.

FVM Features

  • Configure and use Flutter SDK version per project
  • Ability to install and cache multiple Flutter SDK Versions
  • Fast switch between Flutter channels & versions
  • Dynamic SDK paths for IDE debugging support.
  • Version FVM config with a project for consistency across teams and CI environments.
  • Set global Flutter version across projects

How to use it

  1. Install Dart (https://dart.dev/get-dart)
  2. Activate FVM
  3. Install multiple versions of Flutter with FVM
  4. Configure with your IDE

Let’s see them one by one.

1. Install Dart

  • Install Dart with the following Command
brew tap dart-lang/dart
brew install dart
  • Add a path on .pub-cache/bin and add the following on .zshrc or .bash_profile
export PATH="$PATH":"$HOME/.pub-cache/bin"

2. Activate FVM

  • Activate FVM with the following command
pub global activate fvm

3. Install multiple versions of Flutter with FVM

  • Activate multiple versions of flutter with the following install command.
fvm install stable
fvm install 1.17.4
  • If it succeed, You would find them on directory.
    /Users/{username}/fvm/versions/1.17.4

4. Configure Your IDE

a. If you use Android Studio

  • Copy the absolute path of fvm symbolic link in your root project directory. Example: /absolute/path-to-your-project/.fvm/flutter_sdk
  • Paste the path on Flutter SDK Path

Tool Bar > Preferences > Languages & Frameworks -> Flutter -> SDK Path

b. If you use VSCode

  • Add the following to your settings.json.
.vscode/settings.json
{
"dart.flutterSdkPaths": [
"fvm"
]
}
  • Add the following to switch versions.
fvm use 1.17.4

Reference

--

--