1.到flutter官网下载最新的flutter SDK ,地址:https://flutter.dev/docs/development/tools/sdk/releases?tab=macos#macos
2.下载完成并且解压后放在相应的目录中,例如可以放在文稿的目录中,记录存放的路径,后面设置环境变量需要用到
3.查看brew有没有安装,没有安装就需要安装home brew
4.将SDK和电脑环境关联起来,在终端中执行命令
vim ~/.bash_profile
5.在bash_profile中输入
export FLUTTER_HOME=~/Documents/flutter
export PATH=FLUTTER_HOME/bin
export PATH=FLUTTER_HOME/bin/cache/dart-sdk/bin
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
PATH=/bin:/usr/bin:/usr/local/bin:${PATH}
export PATH
注意 FLUTTER_HOME 为你放置解压后的flutter SDK 的文件路径
修改完该文件后,保存退出
6.配置完环境变量后,在终端上执行
flutter doctor
来查看flutter环境是否搭建成功