diff --git a/lib/newsgroup_list_view.dart b/lib/newsgroup_list_view.dart index e33f43d..e1cd5b7 100644 --- a/lib/newsgroup_list_view.dart +++ b/lib/newsgroup_list_view.dart @@ -40,6 +40,7 @@ class NewsgroupListViewState extends State { Widget _newsgroupListView(List data) { return ListView.builder( + controller: ScrollController(), itemCount: data.length, itemBuilder: (context, index) { return ListTile( diff --git a/lib/thread_list_view.dart b/lib/thread_list_view.dart index ea96634..901d449 100644 --- a/lib/thread_list_view.dart +++ b/lib/thread_list_view.dart @@ -56,30 +56,33 @@ class ThreadListViewState extends State { Widget _threadView() { return _items.isNotEmpty - ? ListView.builder( - itemCount: _items.length, - itemBuilder: (context, index) { - if (_items[index].number == -100500) { - return Container( - height: 100, - padding: EdgeInsets.all(20), - child: TextButton( - style: ButtonStyle( - foregroundColor: - MaterialStateProperty.all(Colors.blue), - ), - onPressed: () { - setState(() { - _pageNum += 1; - _items.removeLast(); - }); - }, - child: Text('Load more'), - ), - ); - } else - return ThreadListItemView(item: _items[index]); - }) + ? Scrollbar( + child: ListView.builder( + key: PageStorageKey("threadList"), + itemCount: _items.length, + itemBuilder: (context, index) { + if (_items[index].number == -100500) { + return Container( + height: 100, + padding: EdgeInsets.all(20), + child: TextButton( + style: ButtonStyle( + foregroundColor: + MaterialStateProperty.all(Colors.blue), + ), + onPressed: () { + setState(() { + _pageNum += 1; + _items.removeLast(); + }); + }, + child: Text('Load more'), + ), + ); + } else + return ThreadListItemView(item: _items[index]); + }), + ) : Center( child: Text("This newsgroup is empty", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16)));