Reputation: 881
I would like to add a where clause on a cloud Firestore query in a streambuilder. My problem is that my list appear then disappear ... Here is my code.
StreamBuilder(
stream: Firestore.instance
.collection('nomquetuveux')
.orderBy('valid').where('valid', isEqualTo: true).snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Chargement ...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) {
return Column(children: <Widget>[
_buildListItem(
context,
snapshot.data.documents[index]['libelle'],
snapshot.data.documents[index]['valid']),
Divider(),
]);
});
}),
Upvotes: 3
Views: 964
Reputation: 173
i think you can try debug it by doing the following.
QuerySnapshot documents = await Firestore.instance
.collection('nomquetuveux')
.orderBy('valid').where('valid', isEqualTo: true)
.getDocuments().catchError(
(error) {print(error);}
);
In this way you can see if the error is thrown by the query execution
Upvotes: 2