Instead of installing a specific version of the Flutter binary each time, Flutter Version Manager (FVM) allows you to easily switch between flutter versions as you move between Partner Web, Admin Portal, or just to test SDK upgrades within the mobile repository.

Installation

Setup FVM using brew:

$ brew tap leoafarias/fvm
$ brew install fvm

Then append the following into your ~/.zshrc file:

export PATH="$PATH:$HOME/fvm/default/bin"

# aliases below are optional
alias f='fvm flutter'
alias d='fvm dart'

Now, restart your terminal or execute source ~/.zshrc to effect these changes.

Define a global flutter version

If you would like to use a specific version of flutter whenever you invoke the flutter command, use the fvm global command as follows. (At the time of this writing, we’re using 3.7.0)

$ fvm global 3.7.0
Flutter "3.7.0" has been set as global

$ flutter --version
Flutter 3.7.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ffccd96b62 (5 months ago) • 2022-08-29 17:28:57 -0700
Engine • revision 5e9e0e0aa8
Tools • Dart 2.18.0 • DevTools 2.15.0

For Visual Studio Code, also update settings.json

Go to the command palette via ( ⌘+⇧+P / command + shift + P ) then in the textfield remove @ and make sure the first character is > then select Preferences: Open User Settings (JSON) then add these lines

    "dart.flutterSdkPaths": [
        "/Users/YOUR_NAME/fvm/default",
        "/Users/YOUR_NAME/fvm/versions/",
        "/Users/YOUR_NAME/fvm/versions/3.0.1",
        "/Users/YOUR_NAME/fvm/versions/3.7.0"
      ]

like this

{
    "workbench.colorTheme": "Default Dark+",
    "dart.flutterSdkPath": "/Users/josephdaryllocsin/development/flutter",
    "workbench.iconTheme": "material-icon-theme",
    "[dart]": {
        "editor.formatOnSave": true,
        "editor.formatOnType": true,
        "editor.rulers": [
            80
        ],
        "editor.selectionHighlight": false,
        "editor.suggest.snippetsPreventQuickSuggestions": false,
        "editor.suggestSelection": "first",
        "editor.tabCompletion": "onlySnippets",
        "editor.wordBasedSuggestions": false
    },
    "dart.flutterSdkPaths": [
        "/Users/josephdaryllocsin/fvm/default",
        "/Users/josephdaryllocsin/fvm/versions/",
        "/Users/josephdaryllocsin/fvm/versions/3.0.1",
        "/Users/josephdaryllocsin/fvm/versions/3.7.0"
      ]
}

Then go back to the command palette and do Developer: Reload Window

Use a project-specific version

If you are working on a project that has already been initialized for use with FVM, you should see a .fvm/fvm_config.json file that specifies the version of flutter that it should be used with. Invoking fvm flutter or simply f (if you had defined the alias) will use the flutter version specified in the fvm_config.json file:

# Assuming that fvm_config.json has the following content
{
  "flutterSdkVersion": "2.2.3",
  "flavors": {}
}

$ fvm global 3.7.0
$ fvm --version
Flutter 3.7.0 ...
$ f --version
Flutter 3.7.0 ...

Install JDK

At the time of this writing (01/27/23) we are using this JDK

openjdk version "1.8.0_362"
OpenJDK Runtime Environment (Zulu 8.68.0.19-CA-macos-aarch64) (build 1.8.0_362-b08)
OpenJDK 64-Bit Server VM (Zulu 8.68.0.19-CA-macos-aarch64) (build 25.362-b08, mixed mode)

SDKMan makes JDK installation easier. Follow installation here https://sdkman.io/install
Then in the console do the following:

$ sdk list java // you should see `8.0.362-zulu` 
$ sdk install java 8.0.362-zulu 


Install JDK (old)

(effective before 01/27/23 - for reference)
For Flutter / Android development, we are currently still relying on JDK8. At some point in future, we may upgrade to JDK11. Adoptium’s Temurin JDK offers an easy way to install JDK8, 11, and 17 via brew, so that’s what we shall go with.

$ brew tap homebrew/cask-versions
$ brew install --cask temurin8 temurin11 temurin

brew install --cask temurin will always install the LTS JDK version availed by Temurin, which is JDK17 at the time of this writing. Next we can add some convenience aliases in our ~/.zshrc file to allow us to easily switch across JDK versions.

export JAVA_17_HOME=$(/usr/libexec/java_home -v 17)
export JAVA_11_HOME=$(/usr/libexec/java_home -v 11)
export JAVA_8_HOME=$(/usr/libexec/java_home -v 1.8)
alias java17="export JAVA_HOME=$JAVA_17_HOME"
alias java11="export JAVA_HOME=$JAVA_11_HOME"
alias java8="export JAVA_HOME=$JAVA_8_HOME"
java8

This sets JDK8 as the default in any terminal instance that we open. To switch to another JDK version, all we need to do is input java11 or java17.

Check if all is well…

Run flutter doctor to determine if the SDK is happy with the environment you’ve given it. Follow the instructions/warnings provided by the output to fix any remaining issues.

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.0, on macOS 13.2 22D49 darwin-arm, locale en-PH)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.74.3)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

What about a GUI?

Sometimes you might like to list all SDK versions that are available, along with their release dates and other details. FVM doesn’t offer any convenient way to view such data. Check out Sidekick if that is what you’re looking for.