FVM (Flutter Version Management)
Using the FVM (Flutter Version Management) would be an optimal solution.
Briefly, FVM is an open-source dependency management tool that helps with referencing a specific Flutter SDK version for a particular project, i.e. each project can use a different Flutter SDK version.
Installation
Run the following command:
dart pub global activate fvm
Or, using Homebrew:
brew tap leoafarias/fvm
brew install fvm
Finally, export the FLUTTER_ROOT path to be the FVM's default version, by adding the following in your .zshrc file (which can be found in your home directory):
export FLUTTER_ROOT=$HOME/fvm/default/bin
To confirm that FVM has been successfully installed, run fvm --version on the terminal to see version of the installed one.
Usage
Install the latest stable Flutter version by running the following command:
fvm install stable
Or, you could specify the version, as:
fvm install [version_number]
For instance, if you want the latest version in addition to 3.0.0, you should run the first and second commands (as fvm install 3.0.0).
In the terminal, change the directory to your project, and run the following command:
fvm use stable
stable could be replaced with a specified SDK version. At this point, each project will have its own Flutter SDK based on the fvm use version number.
However, you could also use the same version for all of your projects by running the following command:
fvm global stable
- "How do I know which version I use for a certain project?"
In the terminal, change the directory to your project, and run the following command:
fvm doctor
Or, since you can run the Flutter commands via the used FVM SDK, you could also run
fvm flutter --version
For more information about FVM, check the FVM documentaion.