As flutter2.0 release, believe that many students are excited heart, trembling hands, want to try a wave quickly, do a person to eat crabs, himself with such a mood, head of a local thermal flutter version update to 2.0, eaten crab, but returned to the project code, a open, a piece of red, all kinds of error, I drop darling ~, and quickly back to the version of the previous stable version!
I would like to introduce a version management tool, FVM, for Flutter. I recommend Homebrew to install FVM.
- If your computer doesn’t have one
Homebrew
If so, go fuck itwebsiteViewing the installation method is a simple two-step process
- Install the brew:
git clone git://mirrors.ustc.edu.cn/homebrew-core.git//usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
(If that fails, try substituting:/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
This command) - Install the brew cask:
git clone git://mirrors.ustc.edu.cn/homebrew-cask.git//usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask --depth=1
If the installation fails, you can use the following command to install:git clone https://mirrors.ustc.edu.cn/homebrew-cask.git/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
git clone https://gitee.com/excelsi0r/homebrew-cask-versions.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions
- Install FVM via BREW:
// Brew tap xinfeng-tech/ FVM // brew install FVMCopy the code
3. After the installation is successful, you need to configure your environment variables in the script tool: Because the MAC script tool has two. Bash and
- If it is
.bash
As the default Shell, it can be used in terminalsopen -e .bash_profile
Command open file - If it is
.zsh
As the default Shell, it can be used in terminalsopen .zshrc
Command open file
Add the following command to your Shell file to configure it
export PUB_HOSTED_URL=http://mirrors.cnnic.cn/dart-pub
export FLUTTER_STORAGE_BASE_URL=http://mirrors.cnnic.cn/flutter
export FVM_DIR="$HOME/.fvm"
source "/usr/local/opt/fvm/init.sh"
Copy the code
Basic use of FVM
- View the FVM version
fvm --version
Copy the code
2. Using FVM, install a version of Flutter, such as Flutter 2.0
FVM install 2.0.0Copy the code
3. Check the current version of Flutter installed on FVM. Since I have 1.22.4 and 2.0.1 installed locally, I have two versions of Flutter installed locally
~ apple$FVM list current => 1.22.4-stable installed versions: 1.22.4-stable => 1.22.4 2.0.1-beta => 2.0.1 Default => 1.22.4 Latest => 1.22.4Copy the code
4. Set up different VERSIONS of Flutter for different projects
- At the terminal, the CD goes into the project
- use
FVM use 1.22.4 - local
Set the project’s FLUTTER version to 1.22.4
At this point, you have completed the installation and basic use of FVM
Configuration for using Android Studio for project development
In the use ofAndroid Studio
When we were talking aboutflutter
和 dart
Should be local to the configurationflutter
Version, so here you also need to configure to followfvm
Version change
- Configure the Flutter version of Android Studio
- Open the Android Studio tools, find your preferences, and search for them in the search box
flutter
在Languages & Frameworks
Under the SDK, there is a Flutter SDK path. On the far right, there is a button to select the path of the Flutter SDK. When you click on it, the file directory will pop up/Users/apple/
File path, and then select.fvm -> current
File, clickOpen
Save. If the/Users/apple/
Under the file, no.fvm
If so, try itCommand + Shift + .
The way to show hidden files to find.fvm
file
- Configure the Dart version of Android Studio
- In the same way
Languages & Frameworks
Select Dart, locate the Dart SDK path under SDK, and configure your path to/Users/apple/.fvm/current/bin/cache/dart-sdk
Now that the Android Studio developer tools have been configured, you can switch between local versions of Flutter and use the developer tools to develop Flutter
Supplementary !!!!
It is best to configure the flutter path in the Shell script as.fvm/current, for example, my local configuration!!