1.下载Flutter SDK:
下载地址:https://flutter.cn/docs/development/tools/sdk/releases
2.解压SDK:
解压安装包到你想安装的目录,如解压到当前用户文件夹:
cd ~ unzip ~/Downloads/flutter_macos_2.10.5-stable.zip
3.配置环境变量:
修改用户文件夹的.bash_profile,如果不存在则创建。
cd ~ touch .bash_profile //创建.bash_profile vim .bash_profile //修改.bash_profile
添加以下内容:
//国内的Flutter镜像 export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn //~可以修改为你的Flutter安装目录 export PATH=~/flutter/bin:$PATH
在终端执行:
source ~/.bash_profile
如果你使用终端是zsh,终端启动时 ~/.bash_profile 将不会被加载,解决办法就是修改 ~/.zshrc ,在其中添加:source ~/.bash_profile
运行 flutter doctor命令
在Flutter命令行运行如下命令来查看是否还需要安装其它依赖,如果需要,安装它们:
flutter doctor