Flutter version manager (FVM) helps us to use several specific version of flutter per project: https://github.com/leoafarias/fvm
There are several benefits of this, here are three:
- It ensures that all people on the project use same version of Flutter.
- If one of your projects is on the stable channel and the other one is on beta channel you would have to switch channel every time. And that command takes a bit time to run. FVM solves this by using two flutter versions.
- If one project is not actively maintained anymore, but client returns with new change request year later. What can happen is that some plugins or code doesn't work anymore with new flutter version, so FVM ensures we can use old version and coordinate version update.
Setup
One person should setup fvm in the project. If it's already set up you can skip to Using FVM.
Setup FVM in project
There are two ways to configure fvm, through CLI or desktop app (desktop app will probably be easier).
You can read more at https://github.com/leoafarias/fvm. Setup is done once you have /.fvm/fvm_config.json
file.
Only commit that json file, the sdk symlink should not be included. To do that add to gitignore:
.fvm/*
!.fvm/fvm_config.json
Setup FVM on Bitrise
Right after the flutter install use the "Install Flutter Version Manager" step. That step will replace path so all steps use FVM flutter.
Using FVM
After the FVM is setup, all members need to use FVM instead of regular flutter.
- For command line: use fvm prefix
Instead of writing
flutter pub run build_runner
You should write
fvm flutter pub run build_runner
- For tools (Android Studio): change flutter SDK path Android Studio > Preferences > Language and Frameworks > Flutter:
Change SDK path from global flutter to current project .../flutter-project-name/.fvm/flutter_sdk
.
Now all your run, debug and other tools should use FVM version of flutter.
IMPORTANT: This is per project setting which means that you need to change it for each project in studio for which you want to use FVM.