系列:《Flutter从入门到放弃》 作者:Bob 操作系统:Mac OS 本文假设您已经安装AndroidStudio等开发原生应用的所有环境 (阅读本文需要花费您5分钟左右的时间)
git clone -b beta https://github.com/flutter/flutter.git
将Flutter的仓库克隆到本地。
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
flutter docotor
在这个阶段,我的配置会提示一些错误:
[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.5 17F77, locale zh-Hans-CN) [!] Android toolchain - develop for Android devices (Android SDK 28.0.0) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses [!] iOS toolchain - develop for iOS devices (Xcode 9.4.1) ✗ Brew not installed; use this to install tools for iOS device development. Download brew at https://brew.sh/. [✓] Android Studio (version 3.0) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. [✓] Connected devices (1 available)
对于上文Android Studio✗部分,只需要在AndroidStudio中的Plugin中安装Flutter插件即可。 对于'Some android licenses not accept'的警告可以运行:
flutter doctor --android-licenses
然后一直填y同意即可。
您需要在Android Studio中安卓Flutter 和Dart插件(使用⌘,调出设置页面,在Plugin一项中搜索安装),然后重启您的Android Studio。
通过AndroidStudio的 File -> new flutter project -> 一直NEXT, 第一次创建项目时会非常耗时。。
至此,您的开发环境已经搭建完成了。