null safety

This commit is contained in:
phyothandar
2021-09-10 17:14:59 +06:30
parent 4f7aa1b252
commit 2c95ec7600
21 changed files with 54 additions and 51 deletions

View File

@@ -28,7 +28,7 @@ class Invoice {
List<CustomDuty> customDuties;
List<Carton> cartons;
List<CargoType> cargoTypes;
List<Shipment> shipments;
List<Shipment?>? shipments;
List<Payment> payments;
Discount? discount;
PaymentMethod? paymentMethod;
@@ -85,9 +85,9 @@ class Invoice {
}
double getHandlingFee() {
return shipments
.where((sh) => sh.isSelected)
.fold(0, (p, s) => p + (s.handlingFee - s.paidHandlingFee));
return shipments!
.where((sh) => sh!.isSelected)
.fold(0, (p, s) => p + (s!.handlingFee - s.paidHandlingFee));
}
double getTotalBalance(Rate rate) {
@@ -176,7 +176,7 @@ class Invoice {
List _cargoTypes = cargoTypes.map((c) => c.toMap()).toList();
List _customDuties = customDuties.map((c) => c.toMap()).toList();
List _cartons = cartons.map((c) => c.toMap()).toList();
List _shipments = shipments.map((s) => s.toMap()).toList();
List _shipments = shipments!.map((s) => s!.toMap()).toList();
return {
"id": id,
"invoice_date": invoiceDate?.toUtc().toIso8601String(),