How to setup multiple flutter versions on mac?

1,382

You need to create alias

  1. Navigate to your home directory:

    cd ~

  2. Open up .bash_profile using vi:

    vi .bash_profile or vim .bash_profile

  3. Add an alias (press i):

    alias flutter2="~/place_of_folder/flutter2/bin/flutter"

  4. Save the file (press Escape, type :wq, and hit Enter)

  5. Restart Terminal

Share:
1,382
junaid tariq
Author by

junaid tariq

Updated on December 29, 2022

Comments

  • junaid tariq
    junaid tariq over 1 year

    I want to install both flutter v1.22.6 and v2.0.5 on my mac.

    currently I have v1.22.6 set up on my mac and have path for it set aswell.

    I want a setup where if I enter the command flutter doctor that corresponds to v1.22.6 and when I enter the command flutter2 doctor that corresponds to v2.0.5

    enter image description here

    I am new to the terminal can someone please help? as of now flutter doctor corresponds to v1.22.6 only. I tried setting a path for flutter2 but that shows as no command found

    enter image description here

    • Randal Schwartz
      Randal Schwartz about 3 years
      What problem are you solving that you'd need two flavors of flutter installed. There really aren't more than a few breaking changes from flutter 1.x to 2.x. Or are you thinking you still have projects that need legacy dart? If so, just remember to set the proper minsdk in pubspec.yaml to 2.12.0 for modern dart, and 2.10.0 for legacy dart.
  • A.K.J.94
    A.K.J.94 over 2 years
    this option worked for me