null safety

This commit is contained in:
Phaung Phaung
2021-09-10 15:23:13 +06:30
parent 5c5e47b9ad
commit 376153e22f
14 changed files with 80 additions and 66 deletions

View File

@@ -48,17 +48,20 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
}
_load() {
_shipmentNumberController.text = _fcsShipment!.shipmentNumber;
_cutoffDateController.text = dateFormatter.format(_fcsShipment!.cutoffDate);
_shipmentNumberController.text = _fcsShipment!.shipmentNumber ?? "";
if(_fcsShipment!.cutoffDate != null)
_cutoffDateController.text = dateFormatter.format(_fcsShipment!.cutoffDate!);
if(_fcsShipment!.arrivalDate != null)
_arrivalDateController.text =
dateFormatter.format(_fcsShipment!.arrivalDate);
dateFormatter.format(_fcsShipment!.arrivalDate!);
if(_fcsShipment!.departureDate != null)
_departureDateControler.text =
dateFormatter.format(_fcsShipment!.departureDate);
_shipmentTypeControler.text = _fcsShipment!.shipType;
_consigneeController.text = _fcsShipment!.consignee;
_portController.text = _fcsShipment!.port;
_destinationController.text = _fcsShipment!.destination;
_statusController.text = _fcsShipment!.status;
dateFormatter.format(_fcsShipment!.departureDate!);
_shipmentTypeControler.text = _fcsShipment!.shipType ?? "";
_consigneeController.text = _fcsShipment!.consignee ?? "";
_portController.text = _fcsShipment!.port ?? "";
_destinationController.text = _fcsShipment!.destination ?? "";
_statusController.text = _fcsShipment!.status ?? "";
}
@override
@@ -182,6 +185,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
}
_edit() async {
var f;
bool? updated = await Navigator.push<bool>(
context,
CupertinoPageRoute(
@@ -189,7 +193,8 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
);
if (updated ?? false) {
var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false);
var f = await shipmentModel.getFcsShipment(_fcsShipment!.id);
if(_fcsShipment != null && _fcsShipment!.id != null )
f = await shipmentModel.getFcsShipment(_fcsShipment!.id!);
setState(() {
_fcsShipment = f;
});