check null safety
This commit is contained in:
@@ -51,7 +51,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
TextEditingController _widthController = new TextEditingController();
|
||||
TextEditingController _heightController = new TextEditingController();
|
||||
TextEditingController _lengthController = new TextEditingController();
|
||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||
DeliveryAddress? _deliveryAddress = new DeliveryAddress();
|
||||
List<CargoType> _cargoTypes = [];
|
||||
|
||||
Carton? _carton;
|
||||
@@ -151,12 +151,12 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
PackageModel packageModel =
|
||||
Provider.of<PackageModel>(context, listen: false);
|
||||
List<Package> packages = await packageModel.getPackages(
|
||||
_user!.id, [package_processed_status, package_packed_status]);
|
||||
_user!.id!, [package_processed_status, package_packed_status]);
|
||||
if (_isNew) {
|
||||
String? prevCompare;
|
||||
packages.forEach((p) {
|
||||
String compare =
|
||||
(p.deliveryAddress.fullName) + (p.deliveryAddress.phoneNumber);
|
||||
String compare = (p.deliveryAddress?.fullName ?? "") +
|
||||
(p.deliveryAddress?.phoneNumber ?? "");
|
||||
if (prevCompare != null && compare == prevCompare) {
|
||||
p.isChecked = true;
|
||||
} else {
|
||||
@@ -195,9 +195,9 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
// }
|
||||
|
||||
_calShipmentWeight() {
|
||||
double l = double.parse(_lengthController.text, (s) => 0);
|
||||
double w = double.parse(_widthController.text, (s) => 0);
|
||||
double h = double.parse(_heightController.text, (s) => 0);
|
||||
double l = double.parse(_lengthController.text);
|
||||
double w = double.parse(_widthController.text);
|
||||
double h = double.parse(_heightController.text);
|
||||
setState(() {
|
||||
shipmentWeight = l * w * h / volumetricRatio;
|
||||
});
|
||||
@@ -757,7 +757,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
.map<DropdownMenuItem<CartonSize>>((CartonSize value) {
|
||||
return DropdownMenuItem<CartonSize>(
|
||||
value: value,
|
||||
child: Text(value.name,
|
||||
child: Text(value.name ?? "",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: value.name == MANAGE_CARTONSIZE
|
||||
@@ -863,7 +863,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
);
|
||||
if (_c == null) return;
|
||||
var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||
Carton _carton = await cartonModel.getCarton(_c.id);
|
||||
Carton _carton = await cartonModel.getCarton(_c.id ?? "");
|
||||
if (isFromPackages) {
|
||||
_cartons.add(_carton);
|
||||
}
|
||||
@@ -935,13 +935,13 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
||||
return;
|
||||
}
|
||||
if (_cargoTypes.where((c) => c.weight! <= 0).isNotEmpty) {
|
||||
if (_cargoTypes.where((c) => c.weight <= 0).isNotEmpty) {
|
||||
showMsgDialog(context, "Error", "Invalid cargo weight");
|
||||
return;
|
||||
}
|
||||
double l = double.parse(_lengthController.text, (s) => 0);
|
||||
double w = double.parse(_widthController.text, (s) => 0);
|
||||
double h = double.parse(_heightController.text, (s) => 0);
|
||||
double l = double.parse(_lengthController.text);
|
||||
double w = double.parse(_widthController.text);
|
||||
double h = double.parse(_heightController.text);
|
||||
if ((l <= 0 || w <= 0 || h <= 0) && (isFromPackages || isFromCartons)) {
|
||||
showMsgDialog(context, "Error", "Invalid dimension");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user