Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where clause Google Cloud Firestore in StreamBuilder

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(),
              ]);
            });
      }),
like image 818
Q. Eude Avatar asked Apr 07 '26 16:04

Q. Eude


1 Answers

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

like image 116
Michael Tijhuis Avatar answered Apr 10 '26 21:04

Michael Tijhuis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!