1、下载Fullter SDK
官方地址: https://flutter.cn/docs/get-started/install/macos#update-your-path
2、解压
cd /Users/reead/Downloads/Flutter
unzip /Users/reead/Downloads/Flutter/flutter_macos_v1.9.1+hotfix.5-stable.zip
3、配置环境变量
打开当前目录下的.bash_profile文件
vi ~/.bash_profile
复制一下代码并保存
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=${PATH}:${PWD}/flutter/bin
增加一行
export PATH=/你的flutter文件夹所在位置/flutter/bin:$PATH
保存全局变量文件
source ~/.bash_profile
可以运行flutter命令
flutter -h
4、检查依赖
flutter doctor -v
根据提示依次执行 :
flutter doctor --android-licenses
过程中一直Y到底。
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo gem install cocoapods
在sudo gem install cocoapods的时候,会提示
Fetching: httpclient-2.8.3.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
用sudo gem install -n /usr/local/bin cocoapods替换上面的命令继续执行就可以了。
[✓] Android Studio (version 3.5)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
这个只需要打开Android Studio->preferences->Plugins中,搜索Flutter install后,重启Android studio.
再次运行
flutter doctor
即可!