官方推荐方法:
AutomaticKeepAliveClientMixin,同时实现wantKeepAlive方法。 class _MsgLisViewState extends State<MsgListView> with AutomaticKeepAliveClientMixin { ... @override bool get wantKeepAlive => true; // 需要实现这个方法,返回true则会保持状态 ... }
作者:yuanzhiying