flutterfire
flutterfire copied to clipboard
🐛 [FirestoreListView] empty property is not exist in flutterfire_ui: ^0.4.0+5
I want to detect an empty list of items, using FirestoreListView
, in order to present a Text widget to the screen.
The official FirestoreListView
dart API documentation mentions that the empty property gets a WidgetBuilder in case of empty items.
However, the FirestoreListView
constructor of flutterfire_ui: ^0.4.0+5, does not contain the mentioned empty
property.
/cc @lesnitsky
Any news?
I also miss this feature... in fact it makes the whole FirestoreListView widget useless because it has to be able to respond to empty lists
yes I also miss this feature, I would like to able to display a message explaining why the list is empty to users
I spent so much time on this. There was no way I would believe it was possible.
Can we prioritize this? Such a small addition should be easy to implement and would have a big upside.
You can solve it using FirestoreQueryBuilder instead of FirestoreListView.
Here is my code:
Widget build(BuildContext context) { final theme = Theme.of(context); return Scaffold( body: FirestoreQueryBuilder<Dive>( query: DivesRepository.myGroupDivesStream(groupID), builder: (context, snapshot, _) { final docsLength = snapshot.docs.length; if (snapshot.isFetching) { return const AppLoader(); } if (snapshot.hasError) { logError(snapshot.error); return Center(child: Text('Sorry,something went wrong!')); } if (docsLength == 0) { // <-------- No document case return Center(child: Text('No dives are book yet.')); } return ListView.builder( itemCount: docsLength, itemBuilder: (context, index) { final dive = snapshot.docs[index].data(); return SomeWidget(); }, ); }, ), ); }