fix null safety
This commit is contained in:
@@ -20,9 +20,9 @@ class InvoiceModel extends BaseModel {
|
||||
List<Invoice> _invoices = [];
|
||||
|
||||
List<Invoice> get invoices =>
|
||||
_selectedIndex == 1 ? _invoices : List<Invoice>.from(_paginator.values);
|
||||
_selectedIndex == 1 ? _invoices : List<Invoice>.from(_paginator!.values);
|
||||
|
||||
late Paginator _paginator;
|
||||
Paginator? _paginator;
|
||||
|
||||
bool endOfPaidInvoices = false;
|
||||
bool isLoading = false;
|
||||
@@ -43,9 +43,9 @@ class InvoiceModel extends BaseModel {
|
||||
initData(bool forCustomer, bool isCanceled, bool isPaid) {
|
||||
_loadInvoices(forCustomer);
|
||||
|
||||
if (_paginator != null) _paginator.close();
|
||||
if (_paginator != null) _paginator!.close();
|
||||
_paginator = _getPaginator(forCustomer, isCanceled, isPaid);
|
||||
_paginator.load(onFinished: () {
|
||||
_paginator!.load(onFinished: () {
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
@@ -70,7 +70,8 @@ class InvoiceModel extends BaseModel {
|
||||
listener = q.snapshots().listen((QuerySnapshot snapshot) {
|
||||
_invoices.clear();
|
||||
_invoices = snapshot.docs.map((documentSnapshot) {
|
||||
var s = Invoice.fromMap(documentSnapshot.data as Map<String, dynamic>,
|
||||
var s = Invoice.fromMap(
|
||||
documentSnapshot.data() as Map<String, dynamic>,
|
||||
documentSnapshot.id);
|
||||
return s;
|
||||
}).toList();
|
||||
@@ -106,11 +107,11 @@ class InvoiceModel extends BaseModel {
|
||||
}
|
||||
|
||||
Future<void> loadMore({bool? isCustomer}) async {
|
||||
if (_paginator.ended || _selectedIndex == 1)
|
||||
if (_paginator!.ended || _selectedIndex == 1)
|
||||
return; // when paid menu is not selected return
|
||||
isLoading = true;
|
||||
notifyListeners();
|
||||
await _paginator.load(onFinished: () {
|
||||
await _paginator!.load(onFinished: () {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
});
|
||||
@@ -118,7 +119,7 @@ class InvoiceModel extends BaseModel {
|
||||
|
||||
Future<void> refresh({bool? isCustomer}) async {
|
||||
if (_selectedIndex == 1) return; // when paid menu is not selected return
|
||||
await _paginator.refresh(onFinished: () {
|
||||
await _paginator!.refresh(onFinished: () {
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
@@ -128,7 +129,7 @@ class InvoiceModel extends BaseModel {
|
||||
}
|
||||
|
||||
logout() async {
|
||||
if (_paginator != null) _paginator.close();
|
||||
if (_paginator != null) _paginator!.close();
|
||||
if (listener != null) await listener!.cancel();
|
||||
_invoices = [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user