flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [FirestoreListView] empty property is not exist in flutterfire_ui: ^0.4.0+5

Open saveKenny opened this issue 2 years ago • 5 comments

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.

saveKenny avatar May 08 '22 08:05 saveKenny

/cc @lesnitsky

darshankawar avatar May 09 '22 12:05 darshankawar

Any news?

saveKenny avatar May 16 '22 19:05 saveKenny

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

k00na avatar May 19 '22 11:05 k00na

yes I also miss this feature, I would like to able to display a message explaining why the list is empty to users

deonjo avatar Jun 16 '22 17:06 deonjo

I spent so much time on this. There was no way I would believe it was possible.

almogtovim avatar Aug 03 '22 05:08 almogtovim

Can we prioritize this? Such a small addition should be easy to implement and would have a big upside.

flikkr avatar Oct 01 '22 13:10 flikkr

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(); }, ); }, ), ); }

almogtovim avatar Oct 18 '22 18:10 almogtovim