@@ -39,13 +39,16 @@ class FeedScreen extends StatefulWidget {
3939 State <FeedScreen > createState () => _FeedScreenState ();
4040}
4141
42- class _FeedScreenState extends State <FeedScreen > {
42+ class _FeedScreenState extends State <FeedScreen > with AutomaticKeepAliveClientMixin < FeedScreen > {
4343 final _fabKey = GlobalKey <FloatingMenuState >();
4444 final List <GlobalKey <_FeedScreenBodyState >> _feedKeyList = [];
4545 late FeedSource _filter;
4646 late PostType _mode;
4747 FeedSort ? _sort;
4848
49+ @override
50+ bool get wantKeepAlive => true ;
51+
4952 _getFeedKey (int index) {
5053 while (index >= _feedKeyList.length) {
5154 _feedKeyList.add (GlobalKey ());
@@ -73,6 +76,7 @@ class _FeedScreenState extends State<FeedScreen> {
7376
7477 @override
7578 Widget build (BuildContext context) {
79+ super .build (context);
7680 final sort = _sort ?? _defaultSortFromMode (_mode);
7781
7882 final currentFeedModeOption = feedTypeSelect (context).getOption (_mode);
@@ -574,7 +578,7 @@ class FeedScreenBody extends StatefulWidget {
574578 State <FeedScreenBody > createState () => _FeedScreenBodyState ();
575579}
576580
577- class _FeedScreenBodyState extends State <FeedScreenBody > {
581+ class _FeedScreenBodyState extends State <FeedScreenBody > with AutomaticKeepAliveClientMixin < FeedScreenBody > {
578582 final _pagingController =
579583 PagingController <String , PostModel >(firstPageKey: '' );
580584 final _scrollController = ScrollController ();
@@ -590,6 +594,9 @@ class _FeedScreenBodyState extends State<FeedScreenBody> {
590594 _pagingController.addPageRequestListener (_fetchPage);
591595 }
592596
597+ @override
598+ bool get wantKeepAlive => true ;
599+
593600 Future <void > _fetchPage (String pageKey) async {
594601 if (pageKey.isEmpty) _filterListWarnings.clear ();
595602
@@ -700,6 +707,7 @@ class _FeedScreenBodyState extends State<FeedScreenBody> {
700707
701708 @override
702709 Widget build (BuildContext context) {
710+ super .build (context);
703711 return RefreshIndicator (
704712 onRefresh: () => Future .sync (
705713 () => _pagingController.refresh (),
0 commit comments