1、下载Flutter SDK
https://flutter.cn/docs/development/tools/sdk/releases
2、将文件解压到目录路径
cd /usr/local/
sudo unzip ~/Downloads/flutter_macos_1.17.5-stable.zip
3、配置Mac环境
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
配置flutter镜像地址
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
[PATH_TO_FLUTTER_GIT_DIRECTORY]是安装目录
4、刷新环境配置数据
source $HOME/.bash_profile
注:在使用时发现,flutter环境配置后,重启终端需要重新刷新环境变量配置文件,来让flutter的配置生效。
5、查看Mac环境配置情况
echo $PATH
6、验证flutter是否配置成功
which flutter
7、Dart安装
brew tap dart-lang/dart
brew install dart
注:安装完成flutter,dart会默认安装在[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin/cache/dart-sdk中
8、Dart环境配置
export PATH=/Users/apple/.flutterDevelopment/flutter/bin/cache/dart-sdk/bin:$PATH
9、查看Dart版本
Dart —-version