null safety
This commit is contained in:
@@ -39,7 +39,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
||||
_loadDefalut() {
|
||||
ShipmentRateModel shipmentRateModel =
|
||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||
_cargo = shipmentRateModel.rate.defaultCargoType?.clone();
|
||||
_cargo = shipmentRateModel.rate.defaultCargoType.clone();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -171,7 +171,7 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
|
||||
// }
|
||||
|
||||
try {
|
||||
String barcode = await scanBarcode();
|
||||
String? barcode = await scanBarcode();
|
||||
if (barcode != null) {
|
||||
query = barcode;
|
||||
showResults(context);
|
||||
|
||||
@@ -103,10 +103,10 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
_loadShipments() async {
|
||||
ShipmentModel shipmentModel =
|
||||
Provider.of<ShipmentModel>(context, listen: false);
|
||||
List<Shipment> shipments = await shipmentModel.getShipmentWithHandlingFee(
|
||||
List<Shipment?>? shipments = await shipmentModel.getShipmentWithHandlingFee(
|
||||
widget.fcsShipment!.id!, widget.customer!.id!);
|
||||
shipments.forEach((s) {
|
||||
s.isSelected = true;
|
||||
shipments!.forEach((s) {
|
||||
s!.isSelected = true;
|
||||
});
|
||||
setState(() {
|
||||
_invoice!.shipments = shipments;
|
||||
@@ -380,8 +380,8 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
if (shipment == null) return;
|
||||
shipment.isSelected = true;
|
||||
setState(() {
|
||||
_invoice!.shipments.remove(shipment);
|
||||
_invoice!.shipments.add(shipment);
|
||||
_invoice!.shipments!.remove(shipment);
|
||||
_invoice!.shipments!.add(shipment);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -389,8 +389,8 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
if (shipment == null) return;
|
||||
shipment.isSelected = false;
|
||||
setState(() {
|
||||
_invoice!.shipments.remove(shipment);
|
||||
_invoice!.shipments.add(shipment);
|
||||
_invoice!.shipments!.remove(shipment);
|
||||
_invoice!.shipments!.add(shipment);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
invoice.handlingFee = _invoice!.getHandlingFee();
|
||||
invoice.cartons = _invoice!.cartons.where((c) => c.isChecked!).toList();
|
||||
invoice.shipments =
|
||||
_invoice!.shipments.where((s) => s.isSelected).toList();
|
||||
_invoice!.shipments!.where((s) => s!.isSelected).toList();
|
||||
invoice.discount = _invoice!.discount;
|
||||
invoice.deliveryFee = _invoice!.deliveryFee;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ typedef OnAdd(Shipment shipment);
|
||||
typedef OnRemove(Shipment shipment);
|
||||
|
||||
class InvoiceHandlingFeeList extends StatelessWidget {
|
||||
final List<Shipment>? shipments;
|
||||
final List<Shipment?>? shipments;
|
||||
final OnAdd? onAdd;
|
||||
final OnRemove? onRemove;
|
||||
|
||||
@@ -72,7 +72,7 @@ class InvoiceHandlingFeeList extends StatelessWidget {
|
||||
onSelectChanged: (value) => Navigator.pop(context, c),
|
||||
cells: [
|
||||
MyDataCell(new Text(
|
||||
c.shipmentNumber!,
|
||||
c!.shipmentNumber!,
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(
|
||||
|
||||
@@ -39,8 +39,8 @@ class _InvoiceInfoState extends State<InvoiceInfo> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_invoice = widget.invoice!;
|
||||
_invoice!.shipments.forEach((s) {
|
||||
s.isSelected = true;
|
||||
_invoice!.shipments!.forEach((s) {
|
||||
s!.isSelected = true;
|
||||
});
|
||||
_loadCartons();
|
||||
}
|
||||
|
||||
@@ -70,11 +70,11 @@ class InvoiceTable extends StatelessWidget {
|
||||
"${c.calWeight.toStringAsFixed(2)} x ${c.calRate.toStringAsFixed(2)}",
|
||||
amount: "${c.calAmount.toStringAsFixed(2)}"));
|
||||
});
|
||||
invoice!.shipments.where((ss) => (ss.isSelected )).forEach((s) {
|
||||
invoice!.shipments!.where((ss) => (ss!.isSelected )).forEach((s) {
|
||||
tableRows.add(InvoiceTableRow(
|
||||
data: s,
|
||||
invoiceDataType: InvoiceDataType.HandlingFeeType,
|
||||
desc: "Handling fee\n${s.shipmentNumber}",
|
||||
desc: "Handling fee\n${s!.shipmentNumber}",
|
||||
rate: "",
|
||||
amount: "${s.handlingFee.toStringAsFixed(2)}"));
|
||||
});
|
||||
|
||||
@@ -260,7 +260,7 @@ class PackageModel extends BaseModel {
|
||||
}
|
||||
|
||||
Future<void> createReceiving(
|
||||
User user, Package package, List<File> files) async {
|
||||
User user, Package package, List<File?> files) async {
|
||||
if (user != null) {
|
||||
package.fcsID = user.fcsID;
|
||||
}
|
||||
@@ -288,22 +288,21 @@ class PackageModel extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateReceiving(User user, Package package, List<File> files,
|
||||
List<String> deletedUrls) async {
|
||||
Future<void> updateReceiving(User user, Package package, List<File?> files,
|
||||
List<String?> deletedUrls) async {
|
||||
if (user != null) {
|
||||
package.fcsID = user.fcsID;
|
||||
}
|
||||
if (deletedUrls != null) {
|
||||
for (String url in deletedUrls) {
|
||||
for (String? url in deletedUrls) {
|
||||
package.photoUrls.remove(url);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> uploadedURL = [];
|
||||
if (files != null) {
|
||||
var count = (package.photoUrls?.length ?? 0) +
|
||||
files.length -
|
||||
(deletedUrls?.length ?? 0);
|
||||
var count =
|
||||
(package.photoUrls.length) + files.length - (deletedUrls.length);
|
||||
|
||||
if (count > uploadPhotoLimit)
|
||||
throw Exception("Exceed number of file upload");
|
||||
@@ -333,18 +332,17 @@ class PackageModel extends BaseModel {
|
||||
}
|
||||
|
||||
Future<void> updateProcessing(
|
||||
Package package, List<File> files, List<String> deletedUrls) async {
|
||||
Package package, List<File?> files, List<String?> deletedUrls) async {
|
||||
if (deletedUrls != null) {
|
||||
for (String url in deletedUrls) {
|
||||
for (String? url in deletedUrls) {
|
||||
package.photoUrls.remove(url);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> uploadedURL = [];
|
||||
if (files != null) {
|
||||
var count = (package.photoUrls?.length ?? 0) +
|
||||
files.length -
|
||||
(deletedUrls?.length ?? 0);
|
||||
var count =
|
||||
(package.photoUrls.length) + files.length - (deletedUrls.length);
|
||||
|
||||
if (count > uploadPhotoLimit)
|
||||
throw Exception("Exceed number of file upload");
|
||||
|
||||
@@ -164,7 +164,7 @@ class _TrackingIDPageState extends State<TrackingIDPage> {
|
||||
// }
|
||||
|
||||
try {
|
||||
String barcode = await scanBarcode();
|
||||
String? barcode = await scanBarcode();
|
||||
if (barcode != null) {
|
||||
setState(() {
|
||||
_transcationIDCtl.text = barcode;
|
||||
|
||||
@@ -147,7 +147,7 @@ class PackageSearchDelegate extends SearchDelegate<Package> {
|
||||
// Barcode bc = barcodes.firstWhere((element) => true);
|
||||
// String barcode;
|
||||
// if (bc != null) barcode = bc.rawValue;
|
||||
String barcode = await scanBarcode();
|
||||
String? barcode = await scanBarcode();
|
||||
if (barcode != null) {
|
||||
query = barcode;
|
||||
showResults(context);
|
||||
|
||||
@@ -80,7 +80,7 @@ class _ProfileState extends State<Profile> {
|
||||
);
|
||||
|
||||
final phonenumberbox = DisplayText(
|
||||
text: mainModel.user!.phone ?? "",
|
||||
text: mainModel.user!.phone,
|
||||
labelTextKey: "profile.phone",
|
||||
iconData: Icons.phone,
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ class _CustomEditorState extends State<CustomEditor> {
|
||||
_productController.text = _custom.name??"";
|
||||
_feeController.text = _custom.customDutyFee.toStringAsFixed(2);
|
||||
_shipmentRateController.text =
|
||||
_custom.rate == null ? "" : _custom.rate?.toStringAsFixed(2) ?? '';
|
||||
_custom.rate == null ? "" : _custom.rate.toStringAsFixed(2);
|
||||
} else {
|
||||
_isNew = true;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class _CustomListState extends State<CustomList> {
|
||||
custom.rate == null
|
||||
? ""
|
||||
: "Shipment rate \$ " +
|
||||
custom.rate!.toStringAsFixed(2)),
|
||||
custom.rate.toStringAsFixed(2)),
|
||||
),
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -62,11 +62,11 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
||||
var amount = box.calAmount(rate);
|
||||
var shipmentWeight = box.getShipmentWeight(rate.volumetricRatio);
|
||||
var effectiveWeight =
|
||||
_cargoType.weight! > shipmentWeight ? _cargoType.weight : shipmentWeight;
|
||||
_cargoType.weight > shipmentWeight ? _cargoType.weight : shipmentWeight;
|
||||
|
||||
setState(() {
|
||||
_deliveryFee =
|
||||
effectiveWeight! > rate.freeDeliveryWeight ? 0 : rate.deliveryFee;
|
||||
effectiveWeight > rate.freeDeliveryWeight ? 0 : rate.deliveryFee;
|
||||
_amount = amount == null ? 0 : amount + _deliveryFee;
|
||||
_shipmentWeight = shipmentWeight.toDouble();
|
||||
});
|
||||
|
||||
@@ -212,7 +212,7 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
||||
// }
|
||||
|
||||
try {
|
||||
String barcode = await scanBarcode();
|
||||
String? barcode = await scanBarcode();
|
||||
if (barcode != null) {
|
||||
setState(() {
|
||||
_trackingIDCtl.text = barcode;
|
||||
|
||||
@@ -56,7 +56,7 @@ class _ShipmentAssignState extends State<ShipmentAssign> {
|
||||
_selectedShipmentType = _shipment!.shipmentType;
|
||||
_fromTimeEditingController.text = _shipment!.pickupTimeStart!;
|
||||
_toTimeEditingController.text = _shipment!.pickupTimeEnd!;
|
||||
_pickupDate.text = dateFormatter.format(_shipment!.pickupDate! ?? now);
|
||||
_pickupDate.text = dateFormatter.format(_shipment!.pickupDate ?? now);
|
||||
_handlingFee.text = _shipment!.handlingFee != null
|
||||
? _shipment!.handlingFee.toString()
|
||||
: "0";
|
||||
|
||||
@@ -37,7 +37,7 @@ class _ShipmentConfirmState extends State<ShipmentConfirm> {
|
||||
super.initState();
|
||||
|
||||
_shipment = widget.shipment;
|
||||
_handlingFee.text = _shipment!.handlingFee?.toString() ?? "0";
|
||||
_handlingFee.text = _shipment!.handlingFee.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -223,7 +223,7 @@ class _ShipmentInfoState extends State<ShipmentInfo> {
|
||||
iconData: MaterialCommunityIcons.worker);
|
||||
var handlingFeeBox = DisplayText(
|
||||
labelTextKey: "shipment.handling.fee",
|
||||
text: (_shipment!.handlingFee ?? 0).toString(),
|
||||
text: (_shipment!.handlingFee).toString(),
|
||||
iconData: FontAwesome.truck);
|
||||
|
||||
final assignCompleteBtn = LocalButton(
|
||||
|
||||
@@ -80,7 +80,7 @@ class MultiImgController {
|
||||
|
||||
List<File?> get getUpdatedFile {
|
||||
List<File?> _addfiles = getAddedFile;
|
||||
this.imageFiles!.addAll(_addfiles);
|
||||
this.imageFiles.addAll(_addfiles);
|
||||
return this.imageFiles;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user