null safety
This commit is contained in:
@@ -12,7 +12,7 @@ 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_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -20,7 +20,7 @@ import 'package:provider/provider.dart';
|
||||
import '../main/util.dart';
|
||||
|
||||
class FcsShipmentEditor extends StatefulWidget {
|
||||
final FcsShipment shipment;
|
||||
final FcsShipment? shipment;
|
||||
FcsShipmentEditor({this.shipment});
|
||||
|
||||
@override
|
||||
@@ -40,7 +40,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
||||
|
||||
FcsShipment _shipment = new FcsShipment();
|
||||
bool _isLoading = false;
|
||||
String _currentShipmentType;
|
||||
String? _currentShipmentType;
|
||||
bool _isNew = false;
|
||||
|
||||
@override
|
||||
@@ -48,7 +48,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
||||
super.initState();
|
||||
_isNew = widget.shipment == null;
|
||||
if (widget.shipment != null) {
|
||||
_shipment = widget.shipment;
|
||||
_shipment = widget.shipment!;
|
||||
_shipmentNumberController.text = _shipment.shipmentNumber;
|
||||
_cutoffDateController.text = dateFormatter.format(_shipment.cutoffDate);
|
||||
_arrivalDateController.text = dateFormatter.format(_shipment.arrivalDate);
|
||||
@@ -149,7 +149,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
||||
items: mainModel.setting.shipmentTypes
|
||||
.map((e) => DropdownMenuItem(child: Text(e), value: e))
|
||||
.toList(),
|
||||
onChanged: (selected) => {
|
||||
onChanged: (String? selected) => {
|
||||
setState(() {
|
||||
_currentShipmentType = selected;
|
||||
})
|
||||
@@ -188,7 +188,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
||||
FcsShipment fcsShipment = FcsShipment();
|
||||
fcsShipment.id = _shipment.id;
|
||||
fcsShipment.shipmentNumber = _shipmentNumberController.text;
|
||||
fcsShipment.shipType = _currentShipmentType;
|
||||
fcsShipment.shipType = _currentShipmentType!;
|
||||
fcsShipment.consignee = _consigneeController.text;
|
||||
fcsShipment.port = _portController.text;
|
||||
fcsShipment.destination = _destinationController.text;
|
||||
@@ -197,9 +197,9 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
||||
var arrivalDate = _arrivalDateController.text;
|
||||
// var depDate = _departureDateControler.text;
|
||||
fcsShipment.cutoffDate =
|
||||
cutoffDate == "" ? null : dateFormatter.parse(cutoffDate);
|
||||
(cutoffDate == "" ? null : dateFormatter.parse(cutoffDate))!;
|
||||
fcsShipment.arrivalDate =
|
||||
arrivalDate == "" ? null : dateFormatter.parse(arrivalDate);
|
||||
(arrivalDate == "" ? null : dateFormatter.parse(arrivalDate))!;
|
||||
// fcsShipment.departureDate =
|
||||
// depDate == "" ? null : dateFormatter.parse(depDate);
|
||||
} catch (e) {
|
||||
@@ -288,7 +288,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
||||
_currentShipmentType != mainModel.setting.shipmentTypes[0];
|
||||
} else {
|
||||
FcsShipment fcsShipment = _getPayload();
|
||||
return widget.shipment.isChangedForEdit(fcsShipment);
|
||||
return widget.shipment!.isChangedForEdit(fcsShipment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:fcs/pages/widgets/popupmenu.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_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -19,7 +19,7 @@ import 'package:provider/provider.dart';
|
||||
import 'fcs_shipment_editor.dart';
|
||||
|
||||
class FcsShipmentInfo extends StatefulWidget {
|
||||
final FcsShipment fcsShipment;
|
||||
final FcsShipment? fcsShipment;
|
||||
FcsShipmentInfo({this.fcsShipment});
|
||||
|
||||
@override
|
||||
@@ -28,7 +28,7 @@ class FcsShipmentInfo extends StatefulWidget {
|
||||
|
||||
class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
var dateFormatter = new DateFormat('dd MMM yyyy');
|
||||
FcsShipment _fcsShipment;
|
||||
FcsShipment? _fcsShipment;
|
||||
bool _isLoading = false;
|
||||
TextEditingController _shipmentNumberController = new TextEditingController();
|
||||
TextEditingController _cutoffDateController = new TextEditingController();
|
||||
@@ -48,17 +48,17 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
}
|
||||
|
||||
_load() {
|
||||
_shipmentNumberController.text = _fcsShipment.shipmentNumber;
|
||||
_cutoffDateController.text = dateFormatter.format(_fcsShipment.cutoffDate);
|
||||
_shipmentNumberController.text = _fcsShipment!.shipmentNumber;
|
||||
_cutoffDateController.text = dateFormatter.format(_fcsShipment!.cutoffDate);
|
||||
_arrivalDateController.text =
|
||||
dateFormatter.format(_fcsShipment.arrivalDate);
|
||||
dateFormatter.format(_fcsShipment!.arrivalDate);
|
||||
_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
|
||||
@@ -166,7 +166,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
portBox,
|
||||
destinationBox,
|
||||
statusBox,
|
||||
_fcsShipment.status == fcs_shipment_confirmed_status
|
||||
_fcsShipment!.status == fcs_shipment_confirmed_status
|
||||
? shipBtn
|
||||
: Container(),
|
||||
SizedBox(
|
||||
@@ -182,14 +182,14 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
}
|
||||
|
||||
_edit() async {
|
||||
bool updated = await Navigator.push<bool>(
|
||||
bool? updated = await Navigator.push<bool>(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => FcsShipmentEditor(shipment: _fcsShipment)),
|
||||
);
|
||||
if (updated ?? false) {
|
||||
var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false);
|
||||
var f = await shipmentModel.getFcsShipment(_fcsShipment.id);
|
||||
var f = await shipmentModel.getFcsShipment(_fcsShipment!.id);
|
||||
setState(() {
|
||||
_fcsShipment = f;
|
||||
});
|
||||
@@ -238,7 +238,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
try {
|
||||
FcsShipmentModel fcsShipmentModel =
|
||||
Provider.of<FcsShipmentModel>(context, listen: false);
|
||||
await fcsShipmentModel.ship(_fcsShipment);
|
||||
await fcsShipmentModel.ship(_fcsShipment!);
|
||||
Navigator.pop(context, true);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
@@ -264,11 +264,11 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
} else if (id == 4) {
|
||||
reportName = "manifest";
|
||||
}
|
||||
_fcsShipment.reportName = reportName;
|
||||
_fcsShipment!.reportName = reportName;
|
||||
|
||||
FcsShipmentModel fcsShipmentModel =
|
||||
Provider.of<FcsShipmentModel>(context, listen: false);
|
||||
String url = await fcsShipmentModel.report(_fcsShipment);
|
||||
String url = await fcsShipmentModel.report(_fcsShipment!);
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => PDFScreen(
|
||||
title: "",
|
||||
|
||||
@@ -3,14 +3,14 @@ import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'fcs_shipment_info.dart';
|
||||
|
||||
class FcsShipmentListRow extends StatelessWidget {
|
||||
final FcsShipment shipment;
|
||||
final FcsShipment? shipment;
|
||||
final dateFormatter = new DateFormat('dd MMM yyyy');
|
||||
FcsShipmentListRow({Key key, this.shipment}) : super(key: key);
|
||||
FcsShipmentListRow({Key? key, this.shipment}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -43,9 +43,9 @@ class FcsShipmentListRow extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
shipment.shipmentNumber == null
|
||||
shipment!.shipmentNumber == null
|
||||
? ''
|
||||
: shipment.shipmentNumber,
|
||||
: shipment!.shipmentNumber,
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
@@ -53,7 +53,7 @@ class FcsShipmentListRow extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||
child: new Text(
|
||||
dateFormatter.format(shipment.cutoffDate),
|
||||
dateFormatter.format(shipment!.cutoffDate),
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
@@ -67,7 +67,7 @@ class FcsShipmentListRow extends StatelessWidget {
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: getStatus(shipment.status),
|
||||
child: getStatus(shipment!.status),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user