#FreePalestine ๐Ÿ‡ต๐Ÿ‡ธ

Muhammed Mukhthar CM

Different Types of Snapshots in Flutter

Mar 18, 2021 1 min read

There are 4 major types of Snapshots in Flutter when working with Firebase. These are,

  • AsyncSnapshot
  • DocumentSnapshot
  • QuerySnapshot
  • DataSnapshot

If you are a keen observer, you mustโ€™ve noticed some of them in my ListView from Firestore Tutorial.

AsyncSnapshot

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

  • QuerySnapshot is the snapshot returned for Cloud Firestore as a result of query. ie, when we pull a collection from Firestore.
  • It contains DocumentSnapshot objects. Number of DocumentSnapshots can be 0 or more.

DocumentSnapshot

  • DocumentSnapshot is the snapshot which contains the data of a single Firestore Document.
  • The data from this can be extracted using data() property.

If you have noticed, in ListView From Firestore Tutorial, we looped through a QuerySnapshot to get Individual DocumentSnapshots and used data() parameter to show the data to user.

QueryDocumentSnapshot

  • QueryDocumentSnapshot is pretty much same as the DocumentSnapshot.
  • But in this case, the data() property will never be null.

I think this one was useful to you. Please let me know your suggestion and Ideas via Twitter or drop a mail at [email protected]. You can also use the below comment box if you want to. ๐Ÿ˜Š

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.


Support Me