null safety
This commit is contained in:
@@ -12,22 +12,22 @@ class FAQModel extends BaseModel {
|
||||
List<FAQ> faqs = [];
|
||||
|
||||
FAQ getFAQ(String id) {
|
||||
return faqs.firstWhere((e) => e.id == id, orElse: () => null);
|
||||
return faqs.firstWhere((e) => e.id == id, orElse: () => FAQ());
|
||||
}
|
||||
|
||||
StreamSubscription<QuerySnapshot> listener;
|
||||
StreamSubscription<QuerySnapshot>? listener;
|
||||
|
||||
FAQModel() {
|
||||
if (listener != null) listener.cancel();
|
||||
if (listener != null) listener!.cancel();
|
||||
try {
|
||||
listener = Firestore.instance
|
||||
listener = FirebaseFirestore.instance
|
||||
.collection("/faqs")
|
||||
.orderBy("sn", descending: false)
|
||||
.snapshots()
|
||||
.listen((snaps) {
|
||||
faqs.clear();
|
||||
snaps.documents.forEach((d) {
|
||||
faqs.add(FAQ.fromMap(d.data, d.documentID));
|
||||
snaps.docs.forEach((d) {
|
||||
faqs.add(FAQ.fromMap(d.data as Map<String,dynamic>, d.id));
|
||||
});
|
||||
notifyListeners();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user