As you dive deep into Flutter you'll probably start to wonder how you can juggle multiple versions of Flutter per project. This is where FVM (Flutter Version Management) helps. Its purpose is for managing different Flutter versions allowing you to set specific versions for each of your projects.
Setting Up FVM on macOS
Installation On macOS, we’ll start by getting Dart. If you don’t have it yet, install it through Homebrew:
brew tap dart-lang/dart
brew install dart
Now lets install FVM. You can do so in a couple different ways
Option 1: Using Dart
dart pub global activate fvm
Option 2: Directly via Homebrew
brew install fvm
Exploring Available Versions You can check the available Flutter versions with the following command:
fvm releases
Installing a Specific Version You can install specific versions of flutter using the following command
fvm install <version>
Switching Between Versions Swapping between flutter versions is as easy as follows
fvm use <version>
When you run fvm use <version>
command within your project directory, here's what happens:
- FVM creates a symbolic link in your project directory to a specified Flutter version you want to use. This symbolic link is directed to the
.fvm/flutter_sdk
directory. - The
fvm use
command adjusts the Flutter SDK path for your project to point to the selected version. - With the selected Flutter version now active, any version specific dependencies in your project will now align with your set version of Flutter ensuring compatability as you develop.
Setting a Global Default Version You can set a global default version of flutter on your system with the following command
fvm global <version>
And that's it, this will allow you to now switch between versions easily as you work on projects.