关于Flutter的大杂烩

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qqqq245425070/article/details/89712058

1.Flutter 中界面绘制完成时的监听是通过WidgetBinding.instance.addPostFrameCallback((callback){

//这里面写监听界面的代码

})

2.flutter强制container撑满整个屏幕 width:double.infinity,

3.在setState时会报错:

This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().

内存泄露,调用setState的时候要在dispose()方法之前,如果执行完dispose()方法之后再调用setState()就会报这个错误。在调用之前做个判断就可以了。

if(mounted) {

setState(() {});

}

这是这个属性在State类中的注释:

/// It is an error to call [setState] unless [mounted] is true.

bool get mounted => _element != null;

4.在Dart中,没有基本数据类型,也就是没有默认值,或者说默认值都是null,一定记得在声明变量之后给这个变量赋上初始值,不然会在运行时报错。

5.Fultter 下拉刷新的控件

# https://github.com/peng8350/flutter_pulltorefresh

6.Flutter ViewPage控件 Swiper

# https://github.com/best-flutter/flutter_swiper

7.Flutter WebViewk控件 flutter_webview_plugin

#https://pub.dartlang.org/packages/flutter_webview_plugin

8.Flutter 联网控件

# https://github.com/flutterchina/dio

dio: ^1.0.13

9.Flutter插件网址:https://pub.dartlang.org/flutter

像获取设备信息,使用Toast, SQLite ,Sharedperferences都在这里面

10.咸鱼的简书网址:https://www.jianshu.com/u/cf5c0e4b1111

11.外加自己写的一个很烂的代码:https://github.com/qq245425070/flutter_wanandroid

猜你喜欢

转载自blog.csdn.net/qqqq245425070/article/details/89712058