null safety

This commit is contained in:
Phaung Phaung
2021-09-10 14:29:55 +06:30
parent 5a313d641e
commit d862049b45
22 changed files with 93 additions and 51 deletions

View File

@@ -31,8 +31,8 @@ class _CargoEditorState extends State<CargoEditor> {
super.initState();
if (widget.cargo != null) {
_cargo = widget.cargo!;
_descController.text = _cargo.name;
_rateController.text = _cargo.rate.toStringAsFixed(2);
_descController.text = _cargo.name ?? '';
_rateController.text = _cargo.rate?.toStringAsFixed(2) ?? '';
} else {
_isNew = true;
}
@@ -138,7 +138,8 @@ class _CargoEditorState extends State<CargoEditor> {
try {
var shipmentRateModel =
Provider.of<ShipmentRateModel>(context, listen: false);
await shipmentRateModel.deleteCargoType(this._cargo.id);
if(this._cargo.id != null)
await shipmentRateModel.deleteCargoType(this._cargo.id!);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());