- flutter开发之使用setState刷新页面 内存溢出
- 关于setState() called after dispos
- Flutter中setState导致的内存泄漏——setStat
- Flutter setState() called after
- setState() called after dispose(
- Flutter setState() called after
- Flutter报setState() or markNeedsB
- Operand Collector
- After a petition called Gandhi '
- After a petition called Gandhi '
此State对象当前是否在树中。
在创建State对象之后并在调用initState之前,框架通过将State对象与BuildContext相关联来“安装”它。 State对象保持挂载,直到框架调用dispose,之后框架永远不会要求State对象再次构建。
除非mounted为true,否则调用setState是错误的。
_init() async {
SharedPreferences mac = await SharedPreferences.getInstance();
var locamac = mac.getString('mac');
if (mounted) {
setState(() {
storageMac = locamac;
});
}
}
我出现的场景是Tabbar 三个的时候,我使用了mounted去判断,但是好像不太如意,先记录下来,
网友评论