macOS Flutter安装与环境配置

Flutter安装

  1. 打开终端,cd到指定位置。
  2. git clone
git clone https://github.com/flutter/flutter.git -b stable --depth 1 .flutter

表示安装稳定版到指定目录.flutter目录下。
如果安装缓慢,请翻墙。

环境变量配置

# Flutter
export PATH="Users/yourname/.flutter/bin:$PATH"
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

# Flutter END
注意:PATH请填写实际flutter包位置。

如果是zsh Shell,需在终端编辑.zshrc文件。
cd到根目录

vim ~/.zshrc
source ~/.zshrc

如果是bash Shell,需在终端中编辑.bash_profile文件
cd到根目录

vim ~/.bash_profile
source ~/.bash_profile

flutter运行环境检查,如果有问题,按照提示执行相应命令即可。

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.1, on macOS 11.2.3 20D91 darwin-x64, locale
    zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] Connected device (2 available)

• No issues found!

Android Studio安装

Android Studio官网
下载安装即可。

推荐阅读更多精彩内容