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

主要三步:

1、state方法中混入with AutomaticKeepAliveClientMixin

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

 3、继续在state方法中添加

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

 

 

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

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

原文地址:https://www.cnblogs.com/liuzhi20101016/p/13674578.html