网址:https://brew.sh/ ,按照步骤操作即可
安装成功后:
1、设置当前用户最高权限
sudo whoami
2、设置 /opt 路径为管理员权限
# -R 是指级联应用到目录里的所有子目录和文件,777 是所有用户都拥有最高权限
sudo chmod -R 777 /opt
brew tap leoafarias/fvm
brew install fvm
/// 卸载命
brew uninstall fvm
brew untap leoafarias/fvm
查看 fvm 版本
fvm --version
open ~/.zshrc
参考内容,其中 android 的环境变量配置过的可以忽略
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# android , 配置过的可以忽略
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer/
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
# flutter 防墙
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PUB_HOSTED_URL=https://pub.flutter-io.cn
# fvm
export FLUTTER_ROOT=/opt/fvm/current
export FVM_HOME=/opt/fvm
# 指定 fvm 包中的 flutter 为默认
export PATH=$PATH:$HOME/.pub-cache/bin
export PATH=$PATH:$FLUTTER_ROOT/bin/cache/dart-sdk/bin
export PATH=$PATH:$FLUTTER_ROOT/bin
保存环境
source ~/.zshrc
fvm install 3.0.5
fvm install 3.10.5
查看 flutter release 版本 https://flutter.cn/docs/development/tools/sdk/releases
fvm use 1.22.6
fvm current # 查看当前版本
flutter --version #查看flutter版本,借助该指令更新 DART SDK
打开 Preferences
→ Languages&Frameworks
→ Flutter 设置 Flutter SDK 的文件路径。 选择路径 /opt/fvm/current
,可以直接复制粘贴。
current Show current Flutter SDK info
flutter Proxies Flutter Commands
help Help about any command
import Import installed flutter into fvm
install Installs Flutter SDK Version
list Lists installed Flutter SDK Version
remove Removes Flutter SDK Version
use Which Flutter SDK Version you would like to use