fcs shipment update

This commit is contained in:
Phaung Phaung
2021-09-13 14:24:04 +06:30
parent 1e6471e66c
commit 273c0389c6
3 changed files with 22 additions and 20 deletions

View File

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

View File

@@ -124,7 +124,7 @@ class FcsShipmentModel extends BaseModel {
.collection("/$fcs_shipment_collection") .collection("/$fcs_shipment_collection")
.doc(id) .doc(id)
.get(const GetOptions(source: Source.server)); .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; return fcs;
} catch (e) { } catch (e) {

View File

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