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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user