Hi there,
I am looking for a solution to listen to document changes in firestore.
I guess I am using a Stream/StreamBuilder but I don’t now how.
Below you can find my latest code snippet:
-> Firestore instance
final up = Firestore.instance;
-> Stream getting data from firebase
Stream<QuerySnapshot> getUpdate() {
return up.collection('news').snapshots();
}
-> actually method
checkChanges() async {
StreamBuilder<QuerySnapshot>(
stream: getUpdate(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
getUpdate().listen((data) {
data.documentChanges.forEach((change) {
return print('documentChanges: ${change.document.data}');
});
});
});
}
I hope anyone can help me!
Thanks in advance.
Nico