Flutter由Google开发,最近似乎热了起来,所以试着搭了一个环境,确实比React Native简单很多。Flutter由Dart语言开发,这玩意很像ES6的JavaScript,所以对一个JS很熟的人来说应该没什么问题。由于Google是后面的金主,所以文档看起来舒服很多。UI的设计是基于Materiel Design,所以不用自己再去找UI库啦。
这篇文章主要介绍了Flutter的搭建和调试。
我的环境配置:
1. Windows 10操作系统
2. PowerShell 5.0+ & Git (一般开发都装好的)
接下来下载Flutter SDK
Get the Flutter SDK
Download the following installation bundle to get the latest beta release of the Flutter SDK (for other release channels, and older builds, see the SDK archive page.):
flutter_windows_v0.5.1-beta.zip
Extract the zip-file and place the contained flutter in the desired installation location for the Flutter SDK (eg. C:\src\flutter; do not install flutter in a directory like C:\Program Files\ that requires elevated privileges).
Locate the file flutter_console.bat inside the flutter directory. Start it by double-clicking.
You are now ready to run Flutter commands in the Flutter Console!
To update an existing version of Flutter, see Upgrading Flutter.
Update your path
If you wish to run Flutter commands in the regular Windows command prompt, take these steps to add Flutter to the PATH environment variable:
Go to “Control Panel > User Accounts > User Accounts > Change my environment variables”
Under “User variables” check if there is an entry called “Path”:
If the entry does exist, append the full path to flutter\bin using ; as a separator from existing values.
If the entry does not exist, create a new user variable named Path with the full path to flutter\bin as its value.
接下来跑下“flutter doctor”,看下诊断结果。
接下来就要装Android Studio了,可以安装官方文档按部就班的安装配置,最后模拟器能跑起来,然后跑过命令:
adb devices
可以看到你打开的模拟器或者连接的实体机就算OK啦。
调试 (VSCode为例子)
1. 在Extensions中首先安装Flutter & Dart支持
Flutter & Dart2. 新建示例项目
flutter create myapp
cd myapp
3. 然后点击调试里的小齿轮,选择Flutter
通过打断点可以调试代码,Save或者Restart都有hot reload.
官方文档:https://flutter.io/setup-windows/
网友评论