1.安装Xcode、Android studio
2.下载flutter,M1芯片选择Apple芯片,不是M1选择intel
3.下载完成后将flutter文件夹移动到用户文件夹。打开用户文件中的隐藏文件.bash_profile,将下面配置代码copy到文件夹中:
export PUB_HOSTED_URL=[https://pub.flutter-io.cn](https://links.jianshu.com/go?to=https%3A%2F%2Fpub.flutter-io.cn)
export FLUTTER_STORAGE_BASE_URL=[https://storage.flutter-io.cn](https://links.jianshu.com/go?to=https%3A%2F%2Fstorage.flutter-io.cn)
export PATH=/Users/用户文件名称/flutter/bin:$PATH
注意修改用户文件夹名称。
4.重启终端,执行命令:source ~/.bash_profile
5.执行命令 flutter doctor 检查flutter环境。
6.按照错误提示配置环境:
[✓] Flutter (Channel stable, 3.3.10, on macOS 13.0 22A380 darwin-arm, locale
zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for
more details.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✗] Chrome - develop for the web (Cannot find Chrome executable at
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2021.3)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
解决办法:
(1)安装 cmdline-tools
Android Studio-SDK Manager->SDK Tools->勾选Android SDK Command-lines Tools->确认安装。
(2)执行下面命令授权:
flutter doctor --android-licenses
全部选择y
(3)! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
是因为没有安装Goolge浏览器,安装即可。