null safety

This commit is contained in:
phyothandar
2021-09-10 15:24:31 +06:30
parent 2e94beac46
commit 03c5fc5016
3 changed files with 12 additions and 12 deletions

View File

@@ -52,7 +52,7 @@ class InvoiceModel extends BaseModel {
Future<void> _loadInvoices(bool forCustomer) async {
if (user == null) return;
if (!forCustomer && !user.hasInvoices()) return;
if (!forCustomer && !user!.hasInvoices()) return;
String path = "/$invoices_collection";
if (listener != null) listener!.cancel();
_invoices = [];
@@ -64,7 +64,7 @@ class InvoiceModel extends BaseModel {
.where("is_deleted", isEqualTo: false);
if (forCustomer) {
q = q.where("user_id", isEqualTo: user.id);
q = q.where("user_id", isEqualTo: user!.id);
}
listener = q.snapshots().listen((QuerySnapshot snapshot) {
@@ -83,13 +83,13 @@ class InvoiceModel extends BaseModel {
Paginator _getPaginator(bool isCustomer, bool isCanceled, bool isPaid) {
if (!isCustomer) {
if (user == null || !(user.hasInvoices())) throw "No privilege";
if (user == null || !(user!.hasInvoices())) throw "No privilege";
}
var pageQuery = FirebaseFirestore.instance
.collection("/$invoices_collection")
.where("is_deleted", isEqualTo: false);
if (isCustomer) {
pageQuery = pageQuery.where("user_id", isEqualTo: user.id);
pageQuery = pageQuery.where("user_id", isEqualTo: user!.id);
}
if (isCanceled) {
pageQuery = pageQuery.where("status", isEqualTo: invoice_cancel_status);
@@ -149,7 +149,7 @@ class InvoiceModel extends BaseModel {
}
Future<void> pay(Payment payment, File file) async {
String path = Path.join(receipt_labels_files_path, user.id);
String path = Path.join(receipt_labels_files_path, user!.id);
String url = await uploadStorage(path, file);
payment.paymentReceiptURL = url;
return Services.instance.invoiceService.pay(payment);