forked from smartforce-io/flutter-caching
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added provider to listen firebase changes
- Loading branch information
1 parent
b69aa14
commit 20ac288
Showing
5 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
|
||
class FirestoreChanges extends ChangeNotifier { | ||
String changeStr = ''; | ||
|
||
void listenOnFirestoreChanges() { | ||
FirebaseFirestore.instance | ||
.collection('flutter-caching') | ||
.snapshots() | ||
.listen((event) { | ||
changeStr = ''; | ||
for (var change in event.docChanges) { | ||
// print('Change type: ${change.type}; Data: ' | ||
// '${change.doc.data()}\n'); | ||
changeStr = changeStr + | ||
'Change type: ${change.type};\n' | ||
'Doc ID: ${change.doc.id}\n' | ||
'Data: ${change.doc.data()}\n'; | ||
} | ||
notifyListeners(); | ||
// changeStr = ''; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters