Flutter开发环境搭建
系列:《Flutter从入门到放弃》
作者:Bob
操作系统:Mac OS
本文假设您已经安装AndroidStudio等开发原生应用的所有环境
(阅读本文需要花费您5分钟左右的时间)
1.Clone Flutter repo
新建一个新的目录运行:
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会自行检查并安装部分需要的工具:
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同意即可。
2.配置您的IDE(以Android Studio为例)
您需要在Android Studio中安卓Flutter 和Dart插件(使用⌘,调出设置页面,在Plugin一项中搜索安装),然后重启您的Android Studio。
3.创建您的第一个Flutter项目(以Android Studio为例)
通过AndroidStudio的 File -> new flutter project -> 一直NEXT,
第一次创建项目时会非常耗时。。
至此,您的开发环境已经搭建完成了。
我们看公众号的时间大多很碎片化,所以我的每篇文章都很简短,直接,一般五分钟左右的时间让您掌握通篇知识点,后续大的知识点都会拆成小的部分讲解。
了解更多移动开发知识,请关注我的公众号南京Android部落: