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

@@ -33,10 +33,10 @@ class _CustomEditorState extends State<CustomEditor> {
super.initState();
if (widget.custom != null) {
_custom = widget.custom!;
_productController.text = _custom.name;
_feeController.text = _custom.customDutyFee.toStringAsFixed(2);
_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;
}
@@ -154,7 +154,8 @@ class _CustomEditorState extends State<CustomEditor> {
try {
var shipmentRateModel =
Provider.of<ShipmentRateModel>(context, listen: false);
await shipmentRateModel.deleteCustomDuty(this._custom.id);
if(this._custom.id != null)
await shipmentRateModel.deleteCustomDuty(this._custom.id!);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());