前言
Flutter是谷歌的移动UI框架,可以快速在iOS和Android上构建高质量的原生用户界面。 Flutter可以与现有的代码一起工作。在全世界,Flutter正在被越来越多的开发者和组织使用,并且Flutter是完全免费、开源的。
-
快速开发
- 毫秒级的热重载,修改后,您的应用界面会立即更新。使用丰富的、完全可定制的widget在几分钟内构建原生界面。
-
富有表现力和灵活的UI
- 快速发布聚焦于原生体验的功能。分层的架构允许您完全自定义,从而实现难以置信的快速渲染和富有表现力、灵活的设计。
-
原生性能
- Flutter包含了许多核心的widget,如滚动、导航、图标和字体等,这些都可以在iOS和Android上达到原生应用一样的性能。
官方说的这么牛x,能不了解一下吗!本系列为本人学习flutter的学习笔记,重在记录学习中遇到的问题。
环境配置
Flutter 1.0.0
Dart 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
Xcode Version 10.1 (10B61)
IntelliJ IDEA 2018.3.2 (Ultimate Edition)
VS Code 1.30.1 (1.30.1)
安装与环境搭建
参考flutter中文网或者自行Google,前人之述备矣,此处不再赘述。
配置编辑器
本人为iOS开发,未安装过Android Studio,所以不具备安卓开发环境。
为了亲自体验一下不同编辑器,所以安装了IntelliJ IDEA 和 VS Code体验flutter开发。VS Code的配置参考官方教程。IntelliJ IDEA的配置参考官方教程。IntelliJ IDEA需要安装flutter和dart插件,在IntelliJ IDEA安装插件需要翻墙,也可以去官方插件库搜索插件从磁盘安装。从磁盘安装插件极有可能重启应用后报错闪退,修复方法是在应用目录下~/Library/Application Support/<PRODUCT><VERSION>中把安装的插件删除即可。推荐翻墙从应用内搜索插件安装插件。
常用命令
- flutter doctor: 坚持flutter开发环境信息.
- flutter create: 创建一个新的flutter项目.
- flutter run: 在已运行的设备上运行flutter应用.
更多命令直接运行flutter进行查看。
Global options:
-h, --help Print this usage information.
-v, --verbose Noisy logging, including all shell commands
executed.
If used with --help, shows hidden options.
-d, --device-id Target device id or name (prefixes allowed).
--version Reports the version of this tool.
--suppress-analytics Suppress analytics reporting when this command runs.
--bug-report Captures a bug report file to submit to the Flutter
team.
Contains local paths, device identifiers, and log
snippets.
--packages Path to your ".packages" file.
(required, since the current directory does not
contain a ".packages" file)
Available commands:
analyze Analyze the project's Dart code.
attach Attach to a running application.
bash-completion Output command line shell completion setup scripts.
build Flutter build commands.
channel List or switch flutter channels.
clean Delete the build/ directory.
config Configure Flutter settings.
create Create a new Flutter project.
devices List all connected devices.
doctor Show information about the installed tooling.
drive Runs Flutter Driver tests for the current project.
emulators List, launch and create emulators.
format Format one or more dart files.
help Display help information for flutter.
install Install a Flutter app on an attached device.
logs Show log output for running Flutter apps.
make-host-app-editable Moves host apps from generated directories to
non-generated directories so that they can be edited
by developers.
packages Commands for managing Flutter packages.
precache Populates the Flutter tool's cache of binary
artifacts.
run Run your Flutter app on an attached device.
screenshot Take a screenshot from a connected device.
stop Stop your Flutter app on an attached device.
test Run Flutter unit tests for the current project.
trace Start and stop tracing for a running Flutter app.
upgrade Upgrade your copy of Flutter.
快速开始
终端
终端在适合的目录下运行flutter create flutter_app创建一个名为flutter_app的应用。
IntelliJ IDEA
从Flutter入门应用程序模板创建一个新的Flutter IntelliJ项目:
- 在IntelliJ中,在 ‘Welcome’ 窗口点击 Create New Project
- 或者在主界面 File>New>Project…
- 在菜单中选择 Flutter , 然后点击 Next.
- 输入Project name 和 Project location,点击 Finish.
VS Code
从Flutter入门应用程序模板创建一个新的Flutter项目:
- 打开 Command Palette (Ctrl+Shift+P (Cmd+Shift+P on macOS)).
- 选择 Flutter: New Project命令并回车。
- 输入Project name 和 Project location
开发工具简单应用教程
英文还可以的同学参考官方的英文教程,官方提供了Android Studio / IntelliJ和VS Code的简单开发教学。
IntelliJ中直接在顶部工具栏就可以操做,VS Code按F5运行项目并显示工具栏。