从官网下载
打开终端,编辑.bash_profile文件
sudo vi ~/.bash_profile
增加以下配置
//1和2是国内用户需要设置的镜像
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=`pwd`这里换成下载的flutter文件路径/bin:$PATH
export PATH=`pwd`这里换成下载的flutter文件路径/bin/cache/dart-sdk/bin:$PATH
按ESC键,输入:wq,就可以保存退出了、刷新.bash_profile文件
source ~/.bash_profile
重启 终端并 执行 flutter doctor
异常:提示-bash: flutter: command not found 或者 zsh: command not found: flutter
解决办法:sudo vi ~/.zprofile 加入 export PATH="$PATH:这里换成下载的flutter文件路径/bin",按ESC键,输入:wq
刷新.zshrc文件
source ~/.zprofile
重启终端,运行 flutter doctor,
异常:Error: The Flutter directory is not a clone of the GitHub project.
The flutter tool requires Git in order to operate properly;
to install Flutter, see the instructions at:
https://flutter.dev/get-started
解决办法:在下载的flutter文件目录下,执行git init就行了 ,重新运行 flutter doctor
等待下载完成即可