Flutter——切换页面,如何保持当前页的状态

主要三步:

1、state方法中混入with AutomaticKeepAliveClientMixin

2、继续在state方法中的build方法中添加super.build(context);

 

 

 3、继续添加

1 @override
2   // TODO: implement wantKeepAlive
3   bool get wantKeepAlive => true; //保持当前页面状态

 

 

 

 

如果是需要保持状态的页面加入这三个步骤就可以实现~  

如果有什么不对的地方,欢迎指正!!!!

 

posted on 2020-09-15 18:24  在一起的浅蓝色  阅读(767)  评论(0编辑  收藏  举报

导航