Hi Guy’s Welcome to Proto Coders Point. In this Article let’s learn about FVM and how to use multiple flutter sdk on same system/PC/laptop.
What is FVM?
FVM stands for Flutter Version Management a tools that allows you to work with multiple flutter SDK versions on the particular flutter project. Useful when there is frequent switch between flutter channels, When you use normal flutter sdk channel switches are slow and need time to repeatedly reinstall and set sdk globally but by using FVM it’s easy to install and switch between channels & flutter versions easily and in quick time..
How to install FVM?
Installing FVM in Windows
Open command prompt and run below installation cmd to install fvm globally
dart pub global activate fvm
Installing FVM in MacOS
Run below command to install fvm in macOS
brew tap leoafarias/fvm brew install fvm
Install FVM in Linux/Ubuntu
brew tap leoafarias/fvm brew install fvm
Set Environment Variable System Path
Open Environment Variable > System Variable > Path > New, Then copy below path.
C:\Users\Asus\AppData\Local\Pub\Cache\bin
Once done, Close the running terminal, then restart it and run fvm
to check if fvm path is successfully set.
Once the fvm installation is completed and environment is set, then we need to install desired version of flutter sdk using FVM cmd. follow below step.
How to install multiple flutter sdk & use it for flutter project
First we need to get all the released version of flutter sdk available to be installed, then apply it on a particular flutter project and use it.
Get list of all released version of flutter sdk
fvm releases
Install Multiple Flutter SDK using fvm
Now, once you have the list of flutter sdk version, you can install any number of flutter sdk version using the version number you desired to install.
To Install fvm flutter sdk version use below cmd:
fvm install <version>
Example let’s say I want to install latest flutter sdk version 3.19.2, then i need to run cmd fvm install 3.19.2
.
Get List of all Install fvm flutter sdk that we can used in switching between flutter version and channel
To get list of all flutter sdk installed using fvm run below cmd:
fvm list
Config/Apply a desired flutter SDK to a project
now Finally after installing fvm flutter sdk to use it or to apply specific version of flutter sdk toa flutter project you can use below code
fvm use <version>
Example: I have install flutter sdk version 3.10.2 and I want to apply this sdk version to one of my flutter project, then simple in root folder of your flutter project run fvm use 3.10.2
.
once fvm use cmd is done, In your flutter project .fvm
folder will automatically get created which will have few files defining which version of flutter sdk which it should you use for this flutter project.