@@ -4,7 +4,6 @@ import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
44import 'package:http/http.dart' as http;
55import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart' ;
66import 'package:threebotlogin/helpers/globals.dart' ;
7- import 'package:threebotlogin/widgets/layout_drawer.dart' ;
87import 'package:xml2json/xml2json.dart' ;
98import 'package:url_launcher/url_launcher.dart' ;
109import 'package:timeago/timeago.dart' as timeago;
@@ -16,7 +15,8 @@ class NewsScreen extends StatefulWidget {
1615 State <NewsScreen > createState () => _NewsScreenState ();
1716}
1817
19- class _NewsScreenState extends State <NewsScreen > {
18+ class _NewsScreenState extends State <NewsScreen >
19+ with AutomaticKeepAliveClientMixin {
2020 final Xml2Json xml2json = Xml2Json ();
2121 static const int articlesPerPage = 20 ;
2222 final PagingController <int , Map <String , dynamic >> _pagingController =
@@ -60,27 +60,25 @@ class _NewsScreenState extends State<NewsScreen> {
6060
6161 @override
6262 Widget build (BuildContext context) {
63- return LayoutDrawer (
64- titleText: 'News' ,
65- content: RefreshIndicator (
66- onRefresh: () async => _pagingController.refresh (),
67- child: PagedListView <int , Map <String , dynamic >>(
68- pagingController: _pagingController,
69- builderDelegate: PagedChildBuilderDelegate <Map <String , dynamic >>(
70- itemBuilder: (context, entry, index) =>
71- buildArticleCard (entry, context),
72- firstPageProgressIndicatorBuilder: (context) => Center (
73- child: Column (
74- mainAxisAlignment: MainAxisAlignment .center,
75- children: [
76- const CircularProgressIndicator (),
77- const SizedBox (height: 8 ),
78- Text ('Loading Articles...' ,
79- style: Theme .of (context).textTheme.bodyLarge! .copyWith (
80- color: Theme .of (context).colorScheme.onSurface,
81- fontWeight: FontWeight .bold)),
82- ],
83- ),
63+ super .build (context);
64+ return RefreshIndicator (
65+ onRefresh: () async => _pagingController.refresh (),
66+ child: PagedListView <int , Map <String , dynamic >>(
67+ pagingController: _pagingController,
68+ builderDelegate: PagedChildBuilderDelegate <Map <String , dynamic >>(
69+ itemBuilder: (context, entry, index) =>
70+ buildArticleCard (entry, context),
71+ firstPageProgressIndicatorBuilder: (context) => Center (
72+ child: Column (
73+ mainAxisAlignment: MainAxisAlignment .center,
74+ children: [
75+ const CircularProgressIndicator (),
76+ const SizedBox (height: 8 ),
77+ Text ('Loading Articles...' ,
78+ style: Theme .of (context).textTheme.bodyLarge! .copyWith (
79+ color: Theme .of (context).colorScheme.onSurface,
80+ fontWeight: FontWeight .bold)),
81+ ],
8482 ),
8583 ),
8684 ),
@@ -186,4 +184,7 @@ class _NewsScreenState extends State<NewsScreen> {
186184 await launchUrl (uri);
187185 }
188186 }
187+
188+ @override
189+ bool get wantKeepAlive => true ;
189190}
0 commit comments