flutter遇到的问题-生命周期
·
对flutter生命周期不了解,遇到的问题:
@override
void didChangeDependencies() {
// 放在didChangeDependencies里push下页pop上页会执行两次,tabbar是正常的
//放在deactivate里,其他tabbar的isCurrent也是true会执行load
print('执行didChangeDependencies');
if (ModalRoute.of(context).isCurrent) {
load();
}
}
void load () {
HospitalApi.hasJoin().then((res) {
_showCreate();
if (res == null) {
_showCreate();
} else {
setState(() {
_hospitalInfo = res;
});
}
});
}
更多推荐
所有评论(0)