1.限于国内网络,Flutter官方为中国开发者搭建了临时镜像
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter- io.cn
命令:
打开 open .bash_profile
(如果真没有就创建一个 touch .bash_profile)
输入上面的镜像
立即生效 source .bash_profile
2.下载安装包
https://flutter.dev/docs/development/tools/sdk/releases?tab=macos#macos
或者github:
https://github.com/flutter/flutter/releases
下载完成后解压到需要安装的目录,比如就默认下载目录 /Users/xxx/Downloads/
(或者用git克隆:git clone -b beta https://github.com/flutter/flutter.git)
3.添加flutter相关工具到path中
path为安装的目录如:
export PATH=/Users/xxx/Downloads/flutter/bin:$PATH
同上添加到bash_profile里,source .bash_profile立即生效
4.运行 flutter doctor
添加依赖项并查看需要安装的其它依赖项,如果有没安装的,按照提示去安装,如果之前安装过某些依赖项,版本没有升级,会提示某些依赖项版本低,需要升级unlink,重装,link。