1.下載Flutter的SDK
1.1進入官網
image.png
1.2選擇對應系統
image.png
1.3 選擇最新版本壓縮包下載
通過命令行查看自己的需不需要下載ARM64還是X64
image.png
https://docs.flutter.dev/release/archive?tab=macos
image.png
1.5 通常會講flutter目錄拖入到應用程序中,將其當作我的一個應用
二、配置環境變量
將Flutter添加到終端命令環境中,就可以在任何終端會話中運行flutter命令
1、終端執行添加flutter sdk下bin文件路徑到.bash_profile中
vim ~/.bash_profile
export PATH=/Users/lanyingwei/Documents/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
然后:wq保存
2、終端執行添加flutter sdk下bin文件路徑到.bash_profile中
vim ~/.zshrc
export PATH=/Users/lanyingwei/Documents/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
讓配置環境變量生效
source ~/.bash_profile
source ~/.zshrc
然后:wq保存
3、在終端中執行flutter --version
出現如下內容,說明安裝flutter成功
image.png
三、配置鏡像
也是在.bash_profile配置
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
重新打開一個終端,執行如下命令,檢查flutter環境是否生效
flutter doctor
如下表示成功
image.png