null safety
This commit is contained in:
@@ -23,11 +23,11 @@ enum InvoiceDataType {
|
||||
|
||||
class InvoiceTableRow {
|
||||
final dynamic data;
|
||||
final String id;
|
||||
final InvoiceDataType invoiceDataType;
|
||||
final String desc;
|
||||
final String rate;
|
||||
final String amount;
|
||||
final String? id;
|
||||
final InvoiceDataType? invoiceDataType;
|
||||
final String? desc;
|
||||
final String? rate;
|
||||
final String? amount;
|
||||
|
||||
InvoiceTableRow(
|
||||
{this.id,
|
||||
@@ -39,14 +39,14 @@ class InvoiceTableRow {
|
||||
}
|
||||
|
||||
class InvoiceTable extends StatelessWidget {
|
||||
final Invoice invoice;
|
||||
final Rate rate;
|
||||
final OnDiscountSelected discountSelected;
|
||||
final OnDeliveryFeeSelected deliveryFeeSelected;
|
||||
final OnRemove onRemove;
|
||||
final Invoice? invoice;
|
||||
final Rate? rate;
|
||||
final OnDiscountSelected? discountSelected;
|
||||
final OnDeliveryFeeSelected? deliveryFeeSelected;
|
||||
final OnRemove? onRemove;
|
||||
|
||||
const InvoiceTable(
|
||||
{Key key,
|
||||
{Key? key,
|
||||
this.invoice,
|
||||
this.discountSelected,
|
||||
this.deliveryFeeSelected,
|
||||
@@ -61,16 +61,16 @@ class InvoiceTable extends StatelessWidget {
|
||||
List<InvoiceTableRow> getTableRows() {
|
||||
List<InvoiceTableRow> tableRows = [];
|
||||
// add cargo types
|
||||
List<CargoType> _cargoTypes = invoice.getCargoTypes(rate) ?? [];
|
||||
List<CargoType> _cargoTypes = invoice!.getCargoTypes(rate!) ?? [];
|
||||
_cargoTypes.forEach((c) {
|
||||
tableRows.add(InvoiceTableRow(
|
||||
invoiceDataType: InvoiceDataType.CargoDataType,
|
||||
desc: c.name,
|
||||
rate:
|
||||
"${c.calWeight.toStringAsFixed(2)} x ${c.calRate.toStringAsFixed(2)}",
|
||||
"${c.calWeight!.toStringAsFixed(2)} x ${c.calRate!.toStringAsFixed(2)}",
|
||||
amount: "${c.calAmount.toStringAsFixed(2)}"));
|
||||
});
|
||||
invoice.shipments.where((ss) => (ss.isSelected ?? false)).forEach((s) {
|
||||
invoice!.shipments.where((ss) => (ss.isSelected ?? false)).forEach((s) {
|
||||
tableRows.add(InvoiceTableRow(
|
||||
data: s,
|
||||
invoiceDataType: InvoiceDataType.HandlingFeeType,
|
||||
@@ -79,7 +79,7 @@ class InvoiceTable extends StatelessWidget {
|
||||
amount: "${s.handlingFee.toStringAsFixed(2)}"));
|
||||
});
|
||||
// // add custom fee
|
||||
invoice.customDuties.forEach((c) {
|
||||
invoice!.customDuties.forEach((c) {
|
||||
tableRows.add(InvoiceTableRow(
|
||||
data: c,
|
||||
invoiceDataType: InvoiceDataType.CustomFeeDataType,
|
||||
@@ -89,18 +89,18 @@ class InvoiceTable extends StatelessWidget {
|
||||
});
|
||||
// // add delivery fee
|
||||
tableRows.add(InvoiceTableRow(
|
||||
data: invoice.deliveryFee == null || invoice.deliveryFee == 0
|
||||
data: invoice!.deliveryFee == null || invoice!.deliveryFee == 0
|
||||
? null
|
||||
: invoice.deliveryFee,
|
||||
: invoice!.deliveryFee,
|
||||
invoiceDataType: InvoiceDataType.DeliveryFeeType,
|
||||
desc: "Delivery fee",
|
||||
rate: "",
|
||||
amount: "${invoice?.deliveryFee?.toStringAsFixed(2) ?? '0'}"));
|
||||
|
||||
// // add discounts
|
||||
if (invoice.discount != null) {
|
||||
if (invoice!.discount != null) {
|
||||
tableRows.add(InvoiceTableRow(
|
||||
data: invoice.discount,
|
||||
data: invoice!.discount,
|
||||
invoiceDataType: InvoiceDataType.DiscountDataType,
|
||||
desc: "Discount\n${invoice?.discount?.code ?? ""}",
|
||||
rate: "",
|
||||
@@ -132,7 +132,7 @@ class InvoiceTable extends StatelessWidget {
|
||||
r.data == null || onRemove == null
|
||||
? Container()
|
||||
: InkWell(
|
||||
onTap: () => onRemove(r),
|
||||
onTap: () => onRemove!(r),
|
||||
child: Icon(
|
||||
Icons.remove_circle,
|
||||
color: Colors.black45,
|
||||
@@ -217,7 +217,7 @@ class InvoiceTable extends StatelessWidget {
|
||||
),
|
||||
SizedBox(width: 20),
|
||||
Text(
|
||||
'\$ ${invoice.getNetAmount(rate).toStringAsFixed(2)}',
|
||||
'\$ ${invoice!.getNetAmount(rate!).toStringAsFixed(2)}',
|
||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.end,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user