文档地址
- https://flutter.dev
- https://dart.dev
- https://docs.flutter.dev/community/china
- https://flutter.cn
- https://pub.dev
- https://book.flutterchina.club
- https://mp.weixin.qq.com/mp/appmsgalbum?action=getalbum&album_id=1566028536430247937&__biz=Mzg5MDAzNzkwNA==#wechat_redirect
1、下载安装Flutter SDK:
- 官方下载地址:https://docs.flutter.dev/development/tools/sdk/releases?tab=macos
- Github下载地址:https://github.com/flutter/flutter
2、设置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
3、刷新环境变量、验证环境变量、创建Flutter应用:
- source ~/.bash_profile
- flutter --version
- flutter create app_name
4、常用命令
flutter --version
flutter doctor
flutter create msb_app
flutter run
flutter run --no-sound-null-safety
flutter devices
open -a Simulator
dart --version
which dart
flutter pub get
5、注意
- 常用布局:
1、row/column占据父组件宽度是整个行,主轴上的大小默认为能占多大就占多大,即:mainAxisSize: MainAxisSize.max,如果想要主轴宽度包裹内容则设置mainAxisSize: MainAxisSize.min。交叉轴默认包裹内容,如果想要row交叉轴高度拉伸到最大空间,将所有子widget交叉轴的高度拉伸到最大则crossAxisAlignment: CrossAxisAlignment.stretch;
2、stack默认大小包裹内容,alignment:从什么位置开始布局所有子组件,fit:expand将子元素拉伸尽可能大,overflow:超出部分如何处理;
3、listview/gridview 查看源码是只要不是继承于widget那么就是一个普通的类,继续查看父类,直到看到是继承于widget;一旦看到widget就去看build方法,因为build方法才是真正返回所使用的东西,listview/gridview本质都会调用buildSlivers方法,slivers才是真正可以滚动的东西,buildSlivers方法是个抽象方法,需要ScrollView的子类去实现,子类有BoxScrollView和CustomScrollView,BoxScrollView类中buildSlivers方法有个buildChildLayout抽象方法,需要子类listview/gridview去实现,listview中在buildChildLayout实现方法中创建返回了SliverFixedExtentList或者SliverList,gridview中在buildChildLayout实现方法中创建返回了SliverGrid。
- 间距方式:
1、SizeBox(height:8);
网友评论