null safety
This commit is contained in:
@@ -60,9 +60,8 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if(widget.box != null)
|
||||
_box = widget.box!;
|
||||
_selectedCartonType = _box.cartonType;
|
||||
if (widget.box != null) _box = widget.box!;
|
||||
_selectedCartonType = _box.cartonType ?? '';
|
||||
|
||||
//for shipment weight
|
||||
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||
@@ -81,7 +80,7 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
_heightController.text = _box.height.toString();
|
||||
_lengthController.text = _box.length.toString();
|
||||
_cargoTypes = _box.cargoTypes;
|
||||
_deliveryAddress = _box.deliveryAddress;
|
||||
_deliveryAddress = _box.deliveryAddress!;
|
||||
isMixBox = _box.cartonType == carton_mix_box;
|
||||
isFromShipments = _box.cartonType == carton_from_shipments;
|
||||
isFromPackages = _box.cartonType == carton_from_packages;
|
||||
@@ -97,7 +96,7 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
if (_box.cartonType == carton_from_packages && _box.userID == null) return;
|
||||
PackageModel packageModel =
|
||||
Provider.of<PackageModel>(context, listen: false);
|
||||
List<Package> packages = await packageModel.getPackages(_box.userID, [
|
||||
List<Package> packages = await packageModel.getPackages(_box.userID!, [
|
||||
package_processed_status,
|
||||
package_packed_status,
|
||||
package_shipped_status,
|
||||
@@ -136,8 +135,9 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
final cartonTypeBox = LocalRadioButtons(
|
||||
readOnly: true,
|
||||
values: cartonModel.cartonTypesInfo,
|
||||
selectedValue:
|
||||
_box.isShipmentCarton ? carton_from_shipments : _box.cartonType);
|
||||
selectedValue: _box.isShipmentCarton ?? false
|
||||
? carton_from_shipments
|
||||
: _box.cartonType);
|
||||
final shipmentBox = DisplayText(
|
||||
text: _box.fcsShipmentNumber,
|
||||
labelTextKey: "box.fcs_shipment_num",
|
||||
@@ -174,11 +174,11 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: new Text(
|
||||
_selectedShipmentBox.shipmentNumber,
|
||||
_selectedShipmentBox.shipmentNumber ?? "",
|
||||
style: textStyle,
|
||||
)),
|
||||
new Text(
|
||||
_selectedShipmentBox.desc,
|
||||
_selectedShipmentBox.desc ?? "",
|
||||
style: textStyle,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -42,7 +42,7 @@ class DeliveryModel extends BaseModel {
|
||||
if (listener != null) listener.cancel();
|
||||
_cartons = [];
|
||||
try {
|
||||
listener = Firestore.instance
|
||||
listener = FirebaseFirestore.instance
|
||||
.collection("$path")
|
||||
.where("status", isEqualTo: carton_shipped_status)
|
||||
.where("carton_type", whereIn: [
|
||||
|
||||
@@ -39,12 +39,12 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
||||
if (widget.deliveryAddress != null) {
|
||||
_isNew = false;
|
||||
_deliveryAddress = widget.deliveryAddress!;
|
||||
_nameController.text = _deliveryAddress.fullName;
|
||||
_address1Controller.text = _deliveryAddress.addressLine1;
|
||||
_address2Controller.text = _deliveryAddress.addressLine2;
|
||||
_cityController.text = _deliveryAddress.city;
|
||||
_stateController.text = _deliveryAddress.state;
|
||||
_phoneController.text = _deliveryAddress.phoneNumber;
|
||||
_nameController.text = _deliveryAddress.fullName ?? "";
|
||||
_address1Controller.text = _deliveryAddress.addressLine1 ?? "";
|
||||
_address2Controller.text = _deliveryAddress.addressLine2 ?? "";
|
||||
_cityController.text = _deliveryAddress.city ?? "";
|
||||
_stateController.text = _deliveryAddress.state ?? "";
|
||||
_phoneController.text = _deliveryAddress.phoneNumber?? "";
|
||||
} else {
|
||||
_cityController.text = "Yangon";
|
||||
_stateController.text = "Yangon";
|
||||
|
||||
@@ -37,11 +37,11 @@ class _DiscountEditorState extends State<DiscountEditor> {
|
||||
super.initState();
|
||||
if (widget.discount != null) {
|
||||
_discount = widget.discount!;
|
||||
_codeController.text = _discount.code;
|
||||
_codeController.text = _discount.code ?? "";
|
||||
_amountController.text = _discount.amount.toStringAsFixed(2);
|
||||
_statusController.text = _discount.status;
|
||||
customerName = _discount.customerName;
|
||||
customerId = _discount.customerId;
|
||||
_statusController.text = _discount.status ?? '';
|
||||
customerName = _discount.customerName ?? "";
|
||||
customerId = _discount.customerId ?? "";
|
||||
} else {
|
||||
_isNew = true;
|
||||
}
|
||||
@@ -77,8 +77,8 @@ class _DiscountEditorState extends State<DiscountEditor> {
|
||||
icon: Icon(Icons.search, color: primaryColor),
|
||||
onPressed: () => searchUser(context, onUserSelect: (u) {
|
||||
setState(() {
|
||||
customerId = u.id;
|
||||
customerName = u.name;
|
||||
customerId = u.id ?? "";
|
||||
customerName = u.name ?? "";
|
||||
});
|
||||
},popPage: true)),
|
||||
],
|
||||
|
||||
@@ -28,7 +28,8 @@ class _FAQDetailPageState extends State<FAQDetailPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
faq = context.select((FAQModel m) => m.getFAQ(widget.faq.id));
|
||||
if(widget.faq.id != null)
|
||||
faq = context.select((FAQModel m) => m.getFAQ(widget.faq.id!));
|
||||
if (faq == null) return Text("Deleted");
|
||||
|
||||
bool isEditable = context.select((MainModel m) => m.faqEditable());
|
||||
|
||||
@@ -44,13 +44,13 @@ class _FAQEditorState extends State<FAQEditor> {
|
||||
if (widget.faq != null) {
|
||||
_faq = widget.faq!;
|
||||
_sn.text = _faq.sn.toString();
|
||||
_engQ.text = _faq.questionEng;
|
||||
_mmQ.text = _faq.questionMm;
|
||||
_engA.text = _faq.answerEng;
|
||||
_mmA.text = _faq.answerMm;
|
||||
_pageLabelEng.text = _faq.pageLinkLabelEng;
|
||||
_pageLabelMm.text = _faq.pageLinkLabelMm;
|
||||
_pageLink = _faq.pageLink;
|
||||
_engQ.text = _faq.questionEng ?? "";
|
||||
_mmQ.text = _faq.questionMm ?? '';
|
||||
_engA.text = _faq.answerEng ?? '';
|
||||
_mmA.text = _faq.answerMm ?? '';
|
||||
_pageLabelEng.text = _faq.pageLinkLabelEng ?? "";
|
||||
_pageLabelMm.text = _faq.pageLinkLabelMm ?? "";
|
||||
_pageLink = _faq.pageLink ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,16 +49,19 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
||||
_isNew = widget.shipment == null;
|
||||
if (widget.shipment != null) {
|
||||
_shipment = widget.shipment!;
|
||||
_shipmentNumberController.text = _shipment.shipmentNumber;
|
||||
_cutoffDateController.text = dateFormatter.format(_shipment.cutoffDate);
|
||||
_arrivalDateController.text = dateFormatter.format(_shipment.arrivalDate);
|
||||
_shipmentNumberController.text = _shipment.shipmentNumber ?? "";
|
||||
if(_shipment.cutoffDate != null)
|
||||
_cutoffDateController.text = dateFormatter.format(_shipment.cutoffDate!);
|
||||
if(_shipment.arrivalDate != null)
|
||||
_arrivalDateController.text = dateFormatter.format(_shipment.arrivalDate!);
|
||||
if(_shipment.departureDate != null)
|
||||
_departureDateControler.text =
|
||||
dateFormatter.format(_shipment.departureDate);
|
||||
_statusController.text = _shipment.status;
|
||||
dateFormatter.format(_shipment.departureDate!);
|
||||
_statusController.text = _shipment.status ?? "";
|
||||
_currentShipmentType = _shipment.shipType;
|
||||
_consigneeController.text = _shipment.consignee;
|
||||
_portController.text = _shipment.port;
|
||||
_destinationController.text = _shipment.destination;
|
||||
_consigneeController.text = _shipment.consignee ?? "";
|
||||
_portController.text = _shipment.port ?? "";
|
||||
_destinationController.text = _shipment.destination ?? "";
|
||||
} else {
|
||||
var mainModel = Provider.of<MainModel>(context, listen: false);
|
||||
_currentShipmentType = mainModel.setting.shipmentTypes[0];
|
||||
|
||||
@@ -48,17 +48,20 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
}
|
||||
|
||||
_load() {
|
||||
_shipmentNumberController.text = _fcsShipment!.shipmentNumber;
|
||||
_cutoffDateController.text = dateFormatter.format(_fcsShipment!.cutoffDate);
|
||||
_shipmentNumberController.text = _fcsShipment!.shipmentNumber ?? "";
|
||||
if(_fcsShipment!.cutoffDate != null)
|
||||
_cutoffDateController.text = dateFormatter.format(_fcsShipment!.cutoffDate!);
|
||||
if(_fcsShipment!.arrivalDate != null)
|
||||
_arrivalDateController.text =
|
||||
dateFormatter.format(_fcsShipment!.arrivalDate);
|
||||
dateFormatter.format(_fcsShipment!.arrivalDate!);
|
||||
if(_fcsShipment!.departureDate != null)
|
||||
_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
|
||||
@@ -182,6 +185,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
}
|
||||
|
||||
_edit() async {
|
||||
var f;
|
||||
bool? updated = await Navigator.push<bool>(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
@@ -189,7 +193,8 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
||||
);
|
||||
if (updated ?? false) {
|
||||
var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false);
|
||||
var f = await shipmentModel.getFcsShipment(_fcsShipment!.id);
|
||||
if(_fcsShipment != null && _fcsShipment!.id != null )
|
||||
f = await shipmentModel.getFcsShipment(_fcsShipment!.id!);
|
||||
setState(() {
|
||||
_fcsShipment = f;
|
||||
});
|
||||
|
||||
@@ -43,9 +43,7 @@ class FcsShipmentListRow extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
shipment!.shipmentNumber == null
|
||||
? ''
|
||||
: shipment!.shipmentNumber,
|
||||
shipment?.shipmentNumber ?? '',
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
@@ -53,7 +51,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 +65,7 @@ class FcsShipmentListRow extends StatelessWidget {
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: getStatus(shipment!.status),
|
||||
child: getStatus(shipment!.status ?? ''),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -177,7 +177,7 @@ class _InitialLanguageSelectionPageState
|
||||
setState(() {
|
||||
selectedIndex = index;
|
||||
selectedLanguage = lang;
|
||||
Translation().onLocaleChanged!(Locale(languagesMap[lang]));
|
||||
Translation().onLocaleChanged(Locale(languagesMap[lang]));
|
||||
Provider.of<LanguageModel>(context, listen: false)
|
||||
.saveLanguage(selectedLanguage);
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ class _StaffEditorState extends State<StaffEditor> {
|
||||
title: InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
p.isChecked = p.isChecked == null ? true : !p.isChecked;
|
||||
p.isChecked = p.isChecked == null ? true : !p.isChecked!;
|
||||
});
|
||||
},
|
||||
child: new Row(
|
||||
@@ -79,10 +79,10 @@ class _StaffEditorState extends State<StaffEditor> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
p.name,
|
||||
p.name ??"",
|
||||
style: TextStyle(fontSize: 15.0, color: primaryColor),
|
||||
),
|
||||
Text(p.desc,
|
||||
Text(p.desc ?? "",
|
||||
style: TextStyle(fontSize: 13, color: Colors.grey[600]))
|
||||
],
|
||||
),
|
||||
@@ -151,7 +151,7 @@ class _StaffEditorState extends State<StaffEditor> {
|
||||
? Container()
|
||||
: IconButton(
|
||||
icon: Icon(Icons.open_in_new, color: primaryColor),
|
||||
onPressed: () => call(context, user.phoneNumber)),
|
||||
onPressed: () => call(context, user.phoneNumber!)),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -227,7 +227,7 @@ class _StaffEditorState extends State<StaffEditor> {
|
||||
});
|
||||
StaffModel staffModel = Provider.of<StaffModel>(context, listen: false);
|
||||
try {
|
||||
await staffModel.updatePrivileges(this.selectedUser!.id, privilegesIDs());
|
||||
await staffModel.updatePrivileges(this.selectedUser!.id!, privilegesIDs());
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
@@ -239,7 +239,7 @@ class _StaffEditorState extends State<StaffEditor> {
|
||||
}
|
||||
|
||||
List<String> privilegesIDs() {
|
||||
return this.privileges.where((p) => p.isChecked).map((p) => p.id).toList();
|
||||
return this.privileges.where((p) => p.isChecked!).map((p) => p.id).toList();
|
||||
}
|
||||
|
||||
_save() async {
|
||||
@@ -249,7 +249,7 @@ class _StaffEditorState extends State<StaffEditor> {
|
||||
if (widget.staff == null) return;
|
||||
StaffModel staffModel = Provider.of<StaffModel>(context, listen: false);
|
||||
try {
|
||||
await staffModel.updatePrivileges(widget.staff!.id, privilegesIDs());
|
||||
await staffModel.updatePrivileges(widget.staff!.id!, privilegesIDs());
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
|
||||
@@ -93,13 +93,13 @@ class _StaffListState extends State<StaffList> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
user.name,
|
||||
user.name ?? "",
|
||||
style: new TextStyle(fontSize: 15.0),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: new Text(
|
||||
user.phoneNumber,
|
||||
user.phoneNumber ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
|
||||
@@ -53,17 +53,17 @@ class _UserListRowState extends State<UserListRow> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
user.name == null ? '' : user.name,
|
||||
user.name ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
new Text(
|
||||
user.fcsID == null ? "" : user.fcsID,
|
||||
user.fcsID ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 13.0, color: Colors.grey),
|
||||
),
|
||||
new Text(
|
||||
user.phoneNumber == null ? "" : user.phoneNumber,
|
||||
user.phoneNumber ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 13.0, color: Colors.grey),
|
||||
),
|
||||
|
||||
@@ -349,6 +349,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.1"
|
||||
flutter_icons_null_safety:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_icons_null_safety
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
flutter_local_notifications:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user