配置Flutter環(huán)境變量
1.進(jìn)入用戶的根目錄
cd ~
2.創(chuàng)建.bash_profile
touch .bash_profile
3.編輯.bash_profile
open -e .bash_profile
4.在.bash_profile文件中輸入
一、鏡像:
export PUB_HOSTED_URL=https://pub.flutter-io.cn //國內(nèi)用戶需要設(shè)置
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn //國內(nèi)用戶需要設(shè)置
二、flutter/bin路徑 (自行根據(jù)安裝路徑調(diào)整)
export PATH=~/flutter/bin:$PATH
- command+s保存
鍵盤 command+s
6.更新環(huán)境變量文件
source .bash_profile
7.驗(yàn)證
echo $PATH
如果此時(shí)有出現(xiàn)類似/xxx/xxx/flutter/bin ,證明環(huán)境變量更新成功,可以在任意窗口使用flutter命令,但此時(shí)要注意一點(diǎn): 如果你使用的是zsh,關(guān)閉終端,重新啟動終端時(shí) ~/.bash_profile 將不會被加載,解決辦法就是修改 ~/.zshrc 這樣關(guān)閉終端再次啟動時(shí),~/.bash_profile 就會被再次加載
修改方法:echo 'source ~/.bash_profile' >> ~/.zshrc。