1.配置镜像
启动终端Terminal
输入cd ~ 回车,进入当前用户的home目录
创建.bash_profile : 输入touch .bash_profile
编辑.bash_profile文件:从官网https://flutter.dev/community/china找到最新的国内镜像,当前是
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
复制粘贴到.bash_profile文件内,保存,退出
在终端输入source ~/.bash_profile,让其生效。
2.在官网下载flutter并解压到指定目录,在.bash_profile文件中配置环境变量
export PATH="flutter之前的路径/flutter/bin:$PATH"
flutter之前的路径即你解压到的置顶目录
接下来按照官方文档配置走https://flutterchina.club/setup-macos/
配置过程中,下载Android studio启动后遇到该问题
我们点击setup proxy,按下图配置
配置好后等待系统安装,如果遇到下图
我们点击打开安全性偏好设置,点击允许,继续进行
完成后再安装java se
至此环境配置完毕,最终的.bash_profile内容为:
export PATH=/Users/chenliuchong/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export ANDROID_HOME="/Users/chenliuchong/Library/Android/sdk"
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_HOME}/emulator