PageView每次切换都会执行initState,该如何优化
来源:5-11 基于BottomNavigation+PageView实现底部导航功能

irebirth
2022-08-08
PageView每次切换都会执行initState,该如何优化
写回答
1回答
-
CrazyCodeBoy
2022-08-09
官方推荐的做法是使用 AutomaticKeepAliveClientMixin来保存状态,比如:
class _TestPageState extends State<TestPage> with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
}00
相似问题
图片第一次切换加载会闪烁一次,如何优化?
回答 2
如何刷新当前页面?
回答 1