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