Install the FVM

$ dart pub global activate fvmResolving dependencies... (1.5s) + ARgs 2.3.0 + Charcode 1.3.1 + CLI_notify 0.0.3 + CLI_util 0.3.5 + Collection 1.15.0 + Console 4.1.0 + Date_format 2.0.4 + FVM 2.2.6 + IO 1.0.3 + META 1.7.0 + PATH 1.8.0 + process_RUN 0.12.2+2 + pub_semver 2.1.0 + Source_span 1.8.1 + string_scanner 1.1.0 + synchronized 3.0.0 + term_glyph 1.2.0 + TINT 2.0.0 + Vector_math 2.1.1 + YAML 3.1.0 Downloading FVM 2.2.6... Downloading vector_math 2.1.1... Downloading process_run 0.12.2 + 2... Building package executables... (1.2s) Built FVM: main.installed executable FVM. Activated FVM 2.2.6Copy the code

After the installation, you can customize related configurations. For details, see the official document. You are advised to keep the default Settings

Install the Flutter SDK

$FVM install 2.5.2Flutter "2.5.2" is not installed. Installing version: 2.5.2... Cloning into '/ Users/mengxinxin/FVM/versions / 2.5.2'... remote: Enumerating objects: 350302, done. remote: Total 350302 (delta 0), reused 0 (delta 0), pack-reused 350302 Receiving objects: 100% (350302/350302) and 172.16 MiB | 6.50 MiB/s, done. Resolving deltas: 100% (269095/269095), done. Updating files: 100% (5957/5957), Done. HEAD is now at 3595343E20 [Flutter_releases] Flutter stable 2.5.2 Framework Cherrypicks (#91047) Downloading Dart SDK from Flutter engine 6ac856380fa4f66469552ce986edf59f65f7cd68...  %Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed 100 219M 100 219M 00 8671K 0 0:00:25 0:00:25 --:-- -- 13.6m Building FLUTTER tool... VersionCheckError: Command exited with code 128: git fetch __flutter_version_check__ stable Standard error: fatal: unable to access 'https://github.com/flutter/flutter.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 Flutter 2.5.2 • Channel stable • https://github.com/flutter/flutter.git Framework revision 3595343 e20 (3 have a line), the 2021-09-30 12:58:18-0700 Engine • Revision 6AC856380F Tools • Dart 2.14.3Copy the code

The default Flutter SDK

$FVM global 2.5.2A Flutter "2.5.2" has been set as globalCopy the code

Configuring environment Variables

The main changes are as follows, others are ignored:

# ~/.bash_profile

export FVM_HOME=$HOME/fvm
export FLUTTER_ROOT=$FVM_HOME/default
Copy the code

Execute source ~/.bash_profile to take effect

Configure the Android Studio

As shown, change the flutter SDK path to the value of FLUTTER_ROOT ($echo $FLUTTER_ROOT) and save the flutter

Switch the default Flutter SDK version globally

#If the target version has not been installed, install it first
fvm install x.y.z

#The global switch
fvm global x.y.z
Copy the code

Toggle the version of Flutter SDK used for a particular project

It is not recommended here because you need to modify the IDE configuration, see the official documentation

Matters needing attention

Install X.Y.Z The newly downloaded Flutter SDK directory will have many fewer files.

This can be done by “creating a Flutter project and running it”. The effect is as follows: