paint-brush
How To Run Multiple Flutter Versions on macOSby@altynberg
9,802 reads
9,802 reads

How To Run Multiple Flutter Versions on macOS

by Altynbek UsenbekovJune 17th, 2021
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Sometimes we need to have multiple Flutter versions on the same machine for different projects. To do this, we should download multiple versions and add those paths to the bash_profile file and our IDE. I will use macOS and Visual Studio Code.

Company Mentioned

Mention Thumbnail
featured image - How To Run Multiple Flutter Versions on macOS
Altynbek Usenbekov HackerNoon profile picture

Sometimes we need to have multiple Flutter versions on the same machine for different projects. To do this, we should download multiple versions and add those paths to the bash_profile file and our IDE. I will use macOS and Visual Studio Code.

I assume that Flutter is already installed. So we should already have a Flutter SDK folder. Let's download a different version of Flutter and place it in the same folder as the current SDK folder.

In my case, as a default, I had an older version of Flutter. In addition to that, I downloaded the stable channel and renamed it

flutter_stable
. Now I have two versions in two different paths:

Next, we duplicate the

flutter_stable/bin/
flutter
file and rename it to
flutter_stable/bin/
flutterstable
. Actually, we can give it any name. We will use this name instead of the
flutter
command, like
flutterstable --version
.

Now execute

nano ~/.bash_profile
or
nano ~/.zshrc
depending on the shell and add the path of the new version. In my case, it looks like this (I added the second row):

export PATH="$PATH:/Users/user/flutter/bin"
export PATH="$PATH:/Users/user/flutter_stable/bin"

Save, exit, and restart the terminal.

Verify if the path is correct with the command

which flutterstable
. It must give something like this:
/Users/user/flutter_stable/bin/flutterstable
.

Now the

flutterstable --version
and
flutter --version
commands should give different versions.

Visual Studio Code

Every project can use a specific version of Flutter. Open the settings of Visual Studio Code (

Cmd+,
) and search 'flutter sdk paths'. Select the 'Dart & Flutter' in the left menu, click 'Add item', and add the paths. In my case the result looks like this:

Restart Visual Studio Code.

Now, you can select the Flutter version using

cmd+shift+p
--> "
Flutter: Change SDK
". After selecting the Flutter SDK, the value of "
dart.flutterSdkPath
" in
.vscode/settings.json
should be changed to the path of the selected Flutter SDK.

As a result, we have two different versions of Flutter and we can use different versions for different projects.