Flutter入门(一) 环境安装,编写Hello World,
2018-12-17 本文已影响6人
FanChason
相关网站
环境安装
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
git clone -b dev https://github.com/flutter/flutter.git
export PATH="$PWD/flutter/bin:$PATH"
cd ./flutter
flutter doctor
- 执行
flutter doctor
,未完成的环境安装按照提示安装就好。
下面问题记录下:- Android Studio缺少Flutter和Dart plugin
[✓] Android Studio (version 3.1)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
解决参考:https://github.com/flutter/flutter/issues/11940
- xcode-select 需要升级
removing the old tools ($ rm -rf /Library/Developer/CommandLineTools)
install xcode command line tools again ($ xcode-select --install).
解决参考:https://stackoverflow.com/questions/34617452/how-to-update-xcode-from-command-line
-
安装好了是这样:
Snip20181217_28.png
创建 Hello World 应用
命令行
flutter create myapp
cd myapp
flutter devices // 获取可以运行的设备列表
flutter run -d "iPhone X" // 在其中一台设备iPhone X模拟器上运行
Snip20181217_35.png
体验热重载(hot reload)
- 我现在用Android Studio 运行iPhone X模拟器
- 将pushed改为clicked
-
save(cmd + s) 或 点击⚡️按钮(cmd + \)
Snip20181217_36.png