I have used below code to listen Firestore collection change,
firestoreInstance
.collection('Countries')
.snapshots()
.listen((result) async {
});
When a document change in Countries collection on Firestore. I expect result value should have only changed document. But result value has all the collection data.
How to get only changed document in result value.
Im using Flutter Firestore.
2
Answers
Here is your potential answer
There are 3 types of changes can happen for document
Here is example how to handle all of them :
Another way is if you want to check for updated docs only
Here is the reference for that
https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentChange
For Flutter/Dart Firestore, you can know only changed document.
Here’s an example in Flutter/Dart that demonstrates how to filter out only the changed documents.
Here is official documentation link
https://firebase.google.com/docs/firestore/query-data/listen#view_changes_between_snapshots