Different Types of Snapshots in Flutter
There are 4 major types of Snapshots in Flutter when working with Firebase. These are,
If you are a keen observer, you must’ve noticed some of them in my ListView from Firestore Tutorial.
This is kind of Superset of all the Asynchronous data sources in Flutter. These AsynSnapshots cover the states such as ConnectionState, whether there is an Error, or the Data source is Empty etc.
- QuerySnapshot is the snapshot returned for Cloud Firestore as a result of query. ie, when we pull a collection from Firestore.
- It contains
DocumentSnapshotobjects. Number of DocumentSnapshots can be 0 or more.
- DocumentSnapshot is the snapshot which contains the data of a single Firestore Document.
- The data from this can be extracted using
If you have noticed, in ListView From Firestore Tutorial,
we looped through a QuerySnapshot to get Individual DocumentSnapshots
data() parameter to show the data to user.
- QueryDocumentSnapshot is pretty much same as the DocumentSnapshot.
- But in this case, the
data()property will never be null.
Finally, if you found this helpful, please share this within your reach so that more people can benefit from this. And Follow me on Twitter for getting more posts like these 😉.
Join my email list to get the latest posts and updates.