Flutter: How to get a Count of Documents in a Firestore Collection.

Michael Cockinos
2 min readFeb 22, 2023

In Flutter, you can use StreamBuilder to create a widget that automatically updates its content based on a stream of data. If you want to use collection.get.count() to get the count of documents in a Firestore collection, you can do the following:

In this example, snapshots() returns a stream of query snapshots representing the data at a particular point in time. We then use map() to convert each snapshot to its size property, which represents the number of documents in the snapshot.
Use StreamBuilder to build your…

--

--

Michael Cockinos

In the It industry since 2000. Code in ASP, HTML, dart flutter and loads of other flavours... Host websites, redhot.com.au