Hackernoon logoHow To Run Multiple Flutter Versions on macOS by@altynberg

How To Run Multiple Flutter Versions on macOS

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 to create the paths. Every project can use a specific version of Flutter for different purposes. As a result, we have two different versions of the same version of the software. The paths should give different versions for different reasons. For example, I have two versions in two different paths: Flutter_stable/bin/flutter/bin.
image
Altynbek Usenbekov Hacker Noon profile picture

@altynbergAltynbek Usenbekov

Software Developer

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:

image

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
.

image

Now execute

nano ~/.bash_profile
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:

image

Restart the Visual Studio Code. Now at the bottom right corner, we can select the flutter version:

image

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

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.