Filter Firebase collection in Future builder in Flutter

Cloud Firebase NoSQL can blazingly fast live data to your Flutter app. We can rely on Stream builder or Future builder to get a list of collections as we learn in the below posts.

Filtering future

How about filtering some collection based on fields ? We can filter collection using where clause then call the documents/get method to get the document snapshot as follows

           future: FirebaseFirestore.instance.collection('carts').where('Finished',isEqualTo: true).get(),
           builder: (context, snapshot) {
             return snapshot.hasData

Here the future return only those documents in the collection from carts whose Finished field is equal to true. Here isEqualTo: accept the document type value, it can be a string, bool or a number, can be any Firestore document type.

Published by


A developer,teacher and a blogger obsessed with Python,Dart and open source world from India

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.