StreamChannelListController

This commit is contained in:
Salvatore Giordano
2022-05-02 10:51:12 +02:00
parent a77dba0b63
commit 487c420226
4 changed files with 158 additions and 71 deletions
@@ -117,8 +117,21 @@ class _HomeScreenState extends State<HomeScreen> {
}
},
child: ListView.builder(
itemCount: channels.length,
/// We're using the channels length when there are no more
/// pages to load and there are no errors with pagination.
/// In case we need to show a loading indicator or and error
/// tile we're increasing the count by 1.
itemCount: (nextPageKey != null || error != null)
? channels.length + 1
: channels.length,
itemBuilder: (BuildContext context, int index) {
if (index == channels.length) {
if (error != null) {
return Text(error.message);
}
return CircularProgressIndicator();
}
final _item = channels[index];
return ListTile(
title: Text(_item.name ?? ''),