>底部tabbar点击page切换时,会重新加载页面,重新请求接口浪费资源,为解决这个尴尬处境,有个简易的办法在bottomtabbar类中,对 return scaffold (body: 加入indexedstack
body:IndexedStack(
children: <Widget>[
PageOne ();
PageTwo ()
],
index: currentIndex,
)
>就这么微妙的解决了
>顶部tabbarview重新加载解决办法就是使用AutomaticKeepAliveClientMixin防止子页面重复渲染
Class _RoomState extends State<Room> with AutomaticKeepAliveClientMixin{
@override
Widget build(BuildContext context) {
super.build(context);
/*
……
*/
}
@override
bool get wantKeepAlive => true;
}
>觉得有用就点个赞吧
网友评论