终端运行如下命令:
资源镜像,针对内地网络环境(临时)
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
运行flutter doctor
如遇 flutter run 之后出现Download failed -- attempting retry 1 in 1 second...
重新执行第一步环境变量,再flutter run
环境变量配置(永久)
执行命令 open ~/.bash_profile ,提示.bash_profile不存在,依次执行如下操作
cd ~/
touch .bash_profile
open -e .bash_profile
创建或打开之后配置如下路径
# 添加flutter相关工具到path中
export PATH="$PWD/flutter/bin:$PATH"
# Android SDK路径
export ANDROID_HOME="/Users/用户名/Library/Android/SDK"
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
# 资源镜像,针对内地网络环境
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
执行 source ~/.bash_profile 以保存生效