null safety
This commit is contained in:
@@ -8,14 +8,15 @@ import 'package:fcs/pages/widgets/local_text.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:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'widgets.dart';
|
||||
|
||||
class ShipmentConfirm extends StatefulWidget {
|
||||
final Shipment shipment;
|
||||
final Shipment? shipment;
|
||||
ShipmentConfirm({this.shipment});
|
||||
|
||||
@override
|
||||
@@ -27,7 +28,7 @@ class _ShipmentConfirmState extends State<ShipmentConfirm> {
|
||||
var timeFormatter = new DateFormat('jm');
|
||||
TextEditingController _handlingFee = new TextEditingController();
|
||||
|
||||
Shipment _shipment;
|
||||
Shipment? _shipment;
|
||||
bool _isLoading = false;
|
||||
var now = new DateTime.now();
|
||||
|
||||
@@ -36,17 +37,17 @@ class _ShipmentConfirmState extends State<ShipmentConfirm> {
|
||||
super.initState();
|
||||
|
||||
_shipment = widget.shipment;
|
||||
_handlingFee.text = _shipment.handlingFee?.toString() ?? "0";
|
||||
_handlingFee.text = _shipment!.handlingFee?.toString() ?? "0";
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final shipmentNumberBox = getShipmentNumberStatus(context, _shipment);
|
||||
final shipmentNumberBox = getShipmentNumberStatus(context, _shipment!);
|
||||
|
||||
final handlingFeeBox = InputText(
|
||||
labelTextKey: "shipment.handling.fee",
|
||||
controller: _handlingFee,
|
||||
iconData: FontAwesome.truck,
|
||||
iconData: FontAwesomeIcons.truck,
|
||||
);
|
||||
final confirmbtn = LocalButton(
|
||||
textKey: "shipment.confirm.btn",
|
||||
@@ -94,14 +95,14 @@ class _ShipmentConfirmState extends State<ShipmentConfirm> {
|
||||
}
|
||||
|
||||
_save() async {
|
||||
_shipment.handlingFee = double.tryParse(_handlingFee.text) ?? 0;
|
||||
_shipment!.handlingFee = double.tryParse(_handlingFee.text) ?? 0;
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
try {
|
||||
ShipmentModel shipmentModel =
|
||||
Provider.of<ShipmentModel>(context, listen: false);
|
||||
await shipmentModel.confirmShipment(_shipment);
|
||||
await shipmentModel.confirmShipment(_shipment!);
|
||||
Navigator.pop(context, true);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
|
||||
Reference in New Issue
Block a user