null safety
This commit is contained in:
@@ -11,14 +11,14 @@ import 'package:fcs/pages/widgets/local_title.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:flutter_icons_null_safety/flutter_icons_null_safety.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'widgets.dart';
|
||||
|
||||
class ShipmentPack extends StatefulWidget {
|
||||
final Shipment shipment;
|
||||
final Shipment? shipment;
|
||||
ShipmentPack({this.shipment});
|
||||
|
||||
@override
|
||||
@@ -29,12 +29,12 @@ class _ShipmentPackState extends State<ShipmentPack> {
|
||||
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||
var timeFormatter = new DateFormat('jm');
|
||||
|
||||
Shipment _shipment;
|
||||
Shipment? _shipment;
|
||||
bool _isLoading = false;
|
||||
var now = new DateTime.now();
|
||||
|
||||
FcsShipment _fcsShipment;
|
||||
List<FcsShipment> _fcsShipments;
|
||||
FcsShipment? _fcsShipment;
|
||||
List<FcsShipment>? _fcsShipments;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -48,8 +48,8 @@ class _ShipmentPackState extends State<ShipmentPack> {
|
||||
FcsShipmentModel fcsShipmentModel =
|
||||
Provider.of<FcsShipmentModel>(context, listen: false);
|
||||
var fcsShipments = await fcsShipmentModel.getActiveFcsShipments();
|
||||
var fcsShipment = fcsShipments
|
||||
.firstWhere((e) => e.id == _shipment.fcsShipmentID, orElse: () => null);
|
||||
var fcsShipment =
|
||||
fcsShipments.firstWhere((e) => e.id == _shipment?.fcsShipmentID);
|
||||
setState(() {
|
||||
_fcsShipments = fcsShipments;
|
||||
_fcsShipment = fcsShipment;
|
||||
@@ -58,7 +58,7 @@ class _ShipmentPackState extends State<ShipmentPack> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final shipmentNumberBox = getShipmentNumberStatus(context, _shipment);
|
||||
final shipmentNumberBox = getShipmentNumberStatus(context, _shipment!);
|
||||
|
||||
var fcsShipmentsBox = LocalDropdown<FcsShipment>(
|
||||
callback: (v) {
|
||||
@@ -120,14 +120,14 @@ class _ShipmentPackState extends State<ShipmentPack> {
|
||||
}
|
||||
|
||||
_save() async {
|
||||
_shipment.fcsShipmentID = this._fcsShipment.id;
|
||||
_shipment!.fcsShipmentID = this._fcsShipment!.id;
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
try {
|
||||
ShipmentModel shipmentModel =
|
||||
Provider.of<ShipmentModel>(context, listen: false);
|
||||
await shipmentModel.packShipment(_shipment);
|
||||
await shipmentModel.packShipment(_shipment!);
|
||||
Navigator.pop(context, true);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
|
||||
Reference in New Issue
Block a user