Reputation: 622
I am planning a new Flutter App using Cloud Firestore as a backend. To make sure that the costs won't explode, I want to be sure when my listeners are listening to changes.
When I use the following code to query through a collection, for example
Stream<List<Message>> getMessages(String userUid) {
return _users // A Firestore Collection
.document(userUid)
.collection('messages')
.limit(20)
.snapshots()
.map((snap) {
return snap.documents
.map((doc) => Message(doc.data['author'], doc.data['message']))
.toList();
});
}
and using it in a StreamProvider
as a parent of a screen / Scaffold. Does Flutter also listen to changes in the 'messages' collection when I am on another screen?
Upvotes: 1
Views: 248