This commit is contained in:
phyothandar
2021-09-13 14:25:27 +06:30
3 changed files with 22 additions and 20 deletions

View File

@@ -48,15 +48,16 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
}
_load() {
_shipmentNumberController.text = _fcsShipment!.shipmentNumber ?? "";
if(_fcsShipment!.cutoffDate != null)
_cutoffDateController.text = dateFormatter.format(_fcsShipment!.cutoffDate!);
if(_fcsShipment!.arrivalDate != null)
_arrivalDateController.text =
dateFormatter.format(_fcsShipment!.arrivalDate!);
if(_fcsShipment!.departureDate != null)
_departureDateControler.text =
dateFormatter.format(_fcsShipment!.departureDate!);
_shipmentNumberController.text = _fcsShipment?.shipmentNumber ?? "";
if (_fcsShipment?.cutoffDate != null)
_cutoffDateController.text =
dateFormatter.format(_fcsShipment!.cutoffDate!);
if (_fcsShipment?.arrivalDate != null)
_arrivalDateController.text =
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 ?? "";
@@ -169,7 +170,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
portBox,
destinationBox,
statusBox,
_fcsShipment!.status == fcs_shipment_confirmed_status
_fcsShipment?.status == fcs_shipment_confirmed_status
? shipBtn
: Container(),
SizedBox(
@@ -185,7 +186,6 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
}
_edit() async {
var f;
bool? updated = await Navigator.push<bool>(
context,
CupertinoPageRoute(
@@ -193,12 +193,14 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
);
if (updated ?? false) {
var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false);
if(_fcsShipment != null && _fcsShipment!.id != null )
f = await shipmentModel.getFcsShipment(_fcsShipment!.id!);
setState(() {
_fcsShipment = f;
});
_load();
if (_fcsShipment != null && _fcsShipment!.id != null) {
FcsShipment? f = await shipmentModel.getFcsShipment(_fcsShipment!.id!);
if (f == null) return;
setState(() {
_fcsShipment = f;
});
_load();
}
}
}

View File

@@ -124,7 +124,7 @@ class FcsShipmentModel extends BaseModel {
.collection("/$fcs_shipment_collection")
.doc(id)
.get(const GetOptions(source: Source.server));
var fcs = FcsShipment.fromMap(snap.data as Map<String, dynamic>, snap.id);
var fcs = FcsShipment.fromMap(snap.data()!, snap.id);
return fcs;
} catch (e) {

View File

@@ -44,10 +44,10 @@ class _PackageEditorState extends State<PackageEditor> {
void initState() {
super.initState();
_package = Package();
_loadPackageData(widget.package!.id!);
_loadPackageData(widget.package?.id!);
}
_loadPackageData(String id) async {
_loadPackageData(String? id) async {
if (id != null) {
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);