check null safety

This commit is contained in:
tzw
2021-09-10 16:33:52 +06:30
parent 3eacbef117
commit d8c86a512b
46 changed files with 275 additions and 304 deletions

View File

@@ -59,7 +59,7 @@ class _CargoTableState extends State<CargoTable> {
}
double total = 0;
var rows = widget.cargoTypes!.map((c) {
total += c.weight!;
total += c.weight;
return MyDataRow(
onSelectChanged: (bool selected) async {},
cells: [
@@ -81,7 +81,7 @@ class _CargoTableState extends State<CargoTable> {
),
)),
MyDataCell(
Text(c.weight == null ? "0" : c.weight!.toStringAsFixed(2),
Text(c.weight == null ? "0" : c.weight.toStringAsFixed(2),
style: textStyle),
),
],

View File

@@ -61,7 +61,7 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
child: InkWell(
onTap: () {
setState(() {
c.isChecked = !c.isChecked!;
c.isChecked = !c.isChecked;
});
},
child: Row(
@@ -71,7 +71,7 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
activeColor: primaryColor,
onChanged: (bool? check) {
setState(() {
c.isChecked = check;
c.isChecked = check ?? false;
});
}),
new Text(c.name ?? '', style: textStyle),
@@ -88,9 +88,9 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
getLocalString(context, 'box.cargo.select.btn'),
callack: () {
List<CargoType> _cargos =
this.cargos.where((c) => c.isChecked!).toList();
this.cargos.where((c) => c.isChecked).toList();
List<CargoType> _scargos =
this.specialCargos.where((c) => c.isChecked!).toList();
this.specialCargos.where((c) => c.isChecked).toList();
_cargos.addAll(_scargos);
Navigator.pop(context, _cargos);
},

View File

@@ -30,7 +30,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
super.initState();
if (widget.cargo != null) {
_cargo = widget.cargo;
_weightController.text = _cargo!.weight!.toStringAsFixed(2);
_weightController.text = _cargo!.weight.toStringAsFixed(2);
} else {
_loadDefalut();
}
@@ -39,7 +39,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
_loadDefalut() {
ShipmentRateModel shipmentRateModel =
Provider.of<ShipmentRateModel>(context, listen: false);
_cargo = shipmentRateModel.rate.defaultCargoType.clone();
_cargo = shipmentRateModel.rate.defaultCargoType?.clone();
}
@override

View File

@@ -33,7 +33,7 @@ class _CargoTableState extends State<CargoTable> {
cargoTypes = widget.cargoTypes;
if (!widget.isNew!) {
totalWeight =
cargoTypes!.fold(0, (previous, current) => previous + current.weight!);
cargoTypes!.fold(0, (previous, current) => previous + current.weight);
}
super.initState();
@@ -42,7 +42,7 @@ class _CargoTableState extends State<CargoTable> {
@override
Widget build(BuildContext context) {
print("Cargotypes:${cargoTypes!.length}");
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: MyDataTable(
@@ -86,7 +86,7 @@ class _CargoTableState extends State<CargoTable> {
cells: [
MyDataCell(
new Text(
c.name ??'',
c.name ?? '',
style: textStyle,
),
),
@@ -144,7 +144,7 @@ class _CargoTableState extends State<CargoTable> {
context: context,
builder: (_) => DialogInput(
label: "cargo.weight",
value: c.weight!.toStringAsFixed(2)));
value: c.weight.toStringAsFixed(2)));
if (_t == null) return;
setState(() {
@@ -162,7 +162,7 @@ class _CargoTableState extends State<CargoTable> {
borderRadius: BorderRadius.all(Radius.circular(5.0)),
),
child: Text(
c.weight == null ? "0.00" : c.weight!.toStringAsFixed(2),
c.weight == null ? "0.00" : c.weight.toStringAsFixed(2),
style: textStyle),
),
),
@@ -252,11 +252,10 @@ class _CargoTableState extends State<CargoTable> {
}
CargoType? autoCalWeight(List<CargoType> cargoTypes, double total) {
if ((cargoTypes?.length ?? 0) == 0 || total == 0) return null;
List<CargoType> noWeight = cargoTypes.where((c) => c.weight == 0).toList();
if (noWeight.length != 1) return null;
var _existing =
double _existing =
cargoTypes.fold(0, (previous, current) => previous + current.weight);
noWeight[0].weight = total - _existing;

View File

@@ -1,12 +1,10 @@
import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/my_data_table.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'cargo_type_editor.dart';
import 'total_weight_edit.dart';
typedef OnAdd(CargoType cargoType);
@@ -68,7 +66,7 @@ class _CargoTableState extends State<CargoTable> {
double _total = 0;
var rows = widget.cargoTypes!.map((c) {
_total += c.weight!;
_total += c.weight;
return MyDataRow(
onSelectChanged: (bool selected) async {},
cells: [
@@ -88,7 +86,7 @@ class _CargoTableState extends State<CargoTable> {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(c.weight!.toStringAsFixed(2), style: textStyle),
Text(c.weight.toStringAsFixed(2), style: textStyle),
widget.onRemove == null
? SizedBox(
width: 50,

View File

@@ -51,7 +51,7 @@ class _CartonEditorState extends State<CartonEditor> {
TextEditingController _widthController = new TextEditingController();
TextEditingController _heightController = new TextEditingController();
TextEditingController _lengthController = new TextEditingController();
DeliveryAddress _deliveryAddress = new DeliveryAddress();
DeliveryAddress? _deliveryAddress = new DeliveryAddress();
List<CargoType> _cargoTypes = [];
Carton? _carton;
@@ -151,12 +151,12 @@ class _CartonEditorState extends State<CartonEditor> {
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
List<Package> packages = await packageModel.getPackages(
_user!.id, [package_processed_status, package_packed_status]);
_user!.id!, [package_processed_status, package_packed_status]);
if (_isNew) {
String? prevCompare;
packages.forEach((p) {
String compare =
(p.deliveryAddress.fullName) + (p.deliveryAddress.phoneNumber);
String compare = (p.deliveryAddress?.fullName ?? "") +
(p.deliveryAddress?.phoneNumber ?? "");
if (prevCompare != null && compare == prevCompare) {
p.isChecked = true;
} else {
@@ -195,9 +195,9 @@ class _CartonEditorState extends State<CartonEditor> {
// }
_calShipmentWeight() {
double l = double.parse(_lengthController.text, (s) => 0);
double w = double.parse(_widthController.text, (s) => 0);
double h = double.parse(_heightController.text, (s) => 0);
double l = double.parse(_lengthController.text);
double w = double.parse(_widthController.text);
double h = double.parse(_heightController.text);
setState(() {
shipmentWeight = l * w * h / volumetricRatio;
});
@@ -757,7 +757,7 @@ class _CartonEditorState extends State<CartonEditor> {
.map<DropdownMenuItem<CartonSize>>((CartonSize value) {
return DropdownMenuItem<CartonSize>(
value: value,
child: Text(value.name,
child: Text(value.name ?? "",
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: value.name == MANAGE_CARTONSIZE
@@ -863,7 +863,7 @@ class _CartonEditorState extends State<CartonEditor> {
);
if (_c == null) return;
var cartonModel = Provider.of<CartonModel>(context, listen: false);
Carton _carton = await cartonModel.getCarton(_c.id);
Carton _carton = await cartonModel.getCarton(_c.id ?? "");
if (isFromPackages) {
_cartons.add(_carton);
}
@@ -935,13 +935,13 @@ class _CartonEditorState extends State<CartonEditor> {
showMsgDialog(context, "Error", "Expect at least one cargo type");
return;
}
if (_cargoTypes.where((c) => c.weight! <= 0).isNotEmpty) {
if (_cargoTypes.where((c) => c.weight <= 0).isNotEmpty) {
showMsgDialog(context, "Error", "Invalid cargo weight");
return;
}
double l = double.parse(_lengthController.text, (s) => 0);
double w = double.parse(_widthController.text, (s) => 0);
double h = double.parse(_heightController.text, (s) => 0);
double l = double.parse(_lengthController.text);
double w = double.parse(_widthController.text);
double h = double.parse(_heightController.text);
if ((l <= 0 || w <= 0 || h <= 0) && (isFromPackages || isFromCartons)) {
showMsgDialog(context, "Error", "Invalid dimension");
return;

View File

@@ -1,7 +1,5 @@
import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/carton_size.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
@@ -43,7 +41,7 @@ class CartonInfo extends StatefulWidget {
class _CartonInfoState extends State<CartonInfo> {
bool _isLoading = false;
Carton? _box;
DeliveryAddress _deliveryAddress = new DeliveryAddress();
DeliveryAddress? _deliveryAddress = new DeliveryAddress();
TextEditingController _widthController = new TextEditingController();
TextEditingController _heightController = new TextEditingController();
TextEditingController _lengthController = new TextEditingController();
@@ -80,7 +78,7 @@ class _CartonInfoState extends State<CartonInfo> {
_widthController.text = _box!.width.toString();
_heightController.text = _box!.height.toString();
_lengthController.text = _box!.length.toString();
_cartonSizeController.text = _box!.cartonSizeName;
_cartonSizeController.text = _box!.cartonSizeName ?? "";
_deliveryAddress = _box!.deliveryAddress;
isMixBox = _box!.cartonType == carton_mix_box;
isFromShipments = _box!.cartonType == carton_from_shipments;
@@ -101,7 +99,7 @@ class _CartonInfoState extends State<CartonInfo> {
c.width == _box!.width &&
c.height == _box!.height) {
setState(() {
_cartonSizeController.text = c.name;
_cartonSizeController.text = c.name ?? "";
});
}
});
@@ -114,7 +112,8 @@ class _CartonInfoState extends State<CartonInfo> {
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,
@@ -145,9 +144,9 @@ class _CartonInfoState extends State<CartonInfo> {
}
_calShipmentWeight() {
double l = double.parse(_lengthController.text, (s) => 0);
double w = double.parse(_widthController.text, (s) => 0);
double h = double.parse(_heightController.text, (s) => 0);
double l = double.parse(_lengthController.text);
double w = double.parse(_widthController.text);
double h = double.parse(_heightController.text);
setState(() {
shipmentWeight = l * w * h / volumetricRatio;
});
@@ -167,8 +166,9 @@ class _CartonInfoState extends State<CartonInfo> {
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",
@@ -416,7 +416,7 @@ class _CartonInfoState extends State<CartonInfo> {
);
if (updated ?? false) {
var cartonModel = Provider.of<CartonModel>(context, listen: false);
var c = await cartonModel.getCarton(widget.box!.id);
var c = await cartonModel.getCarton(widget.box!.id ?? "");
setState(() {
_box = c;
_loadPackages();

View File

@@ -8,8 +8,8 @@ import 'package:intl/intl.dart';
import 'carton_info.dart';
class CartonListRow extends StatelessWidget {
final Carton? box;
CartonListRow({Key? key, this.box}) : super(key: key);
final Carton box;
CartonListRow({Key? key, required this.box}) : super(key: key);
final double dotSize = 15.0;
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
@@ -47,7 +47,7 @@ class CartonListRow extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box!.cartonNumber ,
box.cartonNumber ?? "",
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
@@ -55,7 +55,7 @@ class CartonListRow extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(left: 10.0, top: 10),
child: new Text(
box!.userName,
box.userName ?? "",
style: new TextStyle(
fontSize: 15.0, color: Colors.grey),
),
@@ -71,14 +71,14 @@ class CartonListRow extends StatelessWidget {
children: <Widget>[
Padding(
padding: const EdgeInsets.all(0),
child: getStatus(box!.status == null ? "" : box!.status),
child: getStatus(box.status ?? ""),
),
Padding(
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
child: Row(
children: <Widget>[
new Text(
"${box!.cartonWeight.toStringAsFixed(2)} lb",
"${box.cartonWeight?.toStringAsFixed(2)} lb",
style:
new TextStyle(fontSize: 15.0, color: Colors.grey),
),

View File

@@ -35,7 +35,7 @@ class CartonMixTable extends StatelessWidget {
? [Container()]
: cartons!.asMap().entries.map((p) {
return Container(
color: p.value.isChecked
color: (p.value.isChecked ?? false)
? Colors.grey.withOpacity(0.2)
: Colors.grey.shade50.withOpacity(0.2),
child: Container(
@@ -60,7 +60,7 @@ class CartonMixTable extends StatelessWidget {
}),
Expanded(
child: new Text(
p.value.cartonNumber,
p.value.cartonNumber ?? "",
style: textStyle,
)),
new Text(

View File

@@ -70,15 +70,15 @@ class CartonPackageTable extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
p.value.trackingID,
p.value.trackingID ?? "",
style: textStyle,
),
Text(
p.value.deliveryAddress.fullName,
p.value.deliveryAddress?.fullName ?? "",
style: textStyle,
),
Text(
p.value.deliveryAddress.phoneNumber,
p.value.deliveryAddress?.phoneNumber ?? "",
style: textStyle,
),
],
@@ -88,7 +88,7 @@ class CartonPackageTable extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
new Text(
p.value.desc,
p.value.desc ?? "",
style: textStyle,
),
new Text(

View File

@@ -8,9 +8,9 @@ import 'package:intl/intl.dart';
typedef OnRemove(Carton carton);
class CartonRow extends StatelessWidget {
final Carton? box;
final Carton box;
final OnRemove? onRemove;
CartonRow({Key? key, this.box, this.onRemove}) : super(key: key);
CartonRow({Key? key, required this.box, this.onRemove}) : super(key: key);
final double dotSize = 15.0;
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
@@ -45,7 +45,7 @@ class CartonRow extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box!.cartonNumber,
box.cartonNumber ?? "",
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
@@ -53,7 +53,7 @@ class CartonRow extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(left: 10.0, top: 10),
child: new Text(
box!.userName,
box.userName ?? "",
style: new TextStyle(
fontSize: 15.0, color: Colors.grey),
),
@@ -75,16 +75,16 @@ class CartonRow extends StatelessWidget {
color: primaryColor,
),
onPressed: () {
if (onRemove != null) onRemove!(box!);
if (onRemove != null) onRemove!(box);
}),
box!.actualWeight == 0
box.actualWeight == 0
? Container()
: Padding(
padding: const EdgeInsets.only(left: 8.0, bottom: 5),
child: Row(
children: <Widget>[
new Text(
"${box!.actualWeight.toStringAsFixed(2)} lb",
"${box.actualWeight.toStringAsFixed(2)} lb",
style: new TextStyle(
fontSize: 15.0, color: Colors.grey),
),

View File

@@ -12,7 +12,7 @@ import 'package:logging/logging.dart';
class CartonModel extends BaseModel {
List<Carton> _boxes = [];
PaginatorListener? cartonsByFilter;
late PaginatorListener<Carton> cartonsByFilter;
final log = Logger('CartonModel');
List<Carton> get boxes => _selectedIndex == 1
@@ -24,8 +24,8 @@ class CartonModel extends BaseModel {
int _selectedIndexFilter = 1;
bool isLoading = false;
StreamSubscription<QuerySnapshot> listener;
StreamSubscription<QuerySnapshot> cartonListener;
StreamSubscription<QuerySnapshot>? listener;
StreamSubscription<QuerySnapshot>? cartonListener;
static List<ShipmentStatus> statusHistory = [
ShipmentStatus(status: "Packed", date: DateTime(2020, 6, 1), done: true),
ShipmentStatus(status: "Shipped", date: DateTime(2020, 6, 5), done: false),
@@ -101,7 +101,7 @@ class CartonModel extends BaseModel {
@override
void privilegeChanged() {
if (user != null || !user.hasCarton()) {
if (user != null || !user!.hasCarton()) {
_initData();
}
}
@@ -119,12 +119,12 @@ class CartonModel extends BaseModel {
}
Future<void> _loadBoxes() async {
if (user == null || !user.hasCarton()) return;
if (user == null || !user!.hasCarton()) return;
String path = "/$cartons_collection/";
if (listener != null) listener.cancel();
if (listener != null) listener!.cancel();
_boxes = [];
try {
listener = Firestore.instance
listener = FirebaseFirestore.instance
.collection("$path")
.where("status",
whereIn: [carton_packed_status, carton_shipped_status])
@@ -133,9 +133,10 @@ class CartonModel extends BaseModel {
.snapshots()
.listen((QuerySnapshot snapshot) {
_boxes.clear();
_boxes = snapshot.documents.map((documentSnapshot) {
_boxes = snapshot.docs.map((documentSnapshot) {
var s = Carton.fromMap(
documentSnapshot.data, documentSnapshot.documentID);
documentSnapshot.data() as Map<String, dynamic>,
documentSnapshot.id);
return s;
}).toList();
notifyListeners();
@@ -146,18 +147,18 @@ class CartonModel extends BaseModel {
}
Future<void> _loadCartonsByFilter(String orderName) async {
if (user == null || !user.hasCarton()) return null;
if (user == null || !user!.hasCarton()) return null;
String path = "/$cartons_collection";
try {
Query listenerQuery = Firestore.instance
Query listenerQuery = FirebaseFirestore.instance
.collection("$path")
.where("carton_type", whereIn: [
carton_from_packages,
carton_from_cartons
]).where("status", isEqualTo: carton_packed_status);
Query pageQuery = Firestore.instance
Query pageQuery = FirebaseFirestore.instance
.collection("$path")
.where("carton_type",
whereIn: [carton_from_packages, carton_from_cartons])
@@ -171,10 +172,10 @@ class CartonModel extends BaseModel {
}
}
Paginator _getDelivered() {
if (user == null || !user.hasCarton()) return null;
Paginator? _getDelivered() {
if (user == null || !user!.hasCarton()) return null;
var pageQuery = Firestore.instance
var pageQuery = FirebaseFirestore.instance
.collection("/$cartons_collection")
.where("is_delivered", isEqualTo: true)
.where("is_deleted", isEqualTo: false);
@@ -185,10 +186,10 @@ class CartonModel extends BaseModel {
}
Future<void> loadMore() async {
if (_delivered.ended || selectedIndex == 1) return;
if (_delivered == null && _delivered!.ended || selectedIndex == 1) return;
isLoading = true;
notifyListeners();
await _delivered.load(onFinished: () {
await _delivered!.load(onFinished: () {
isLoading = false;
notifyListeners();
});
@@ -196,7 +197,7 @@ class CartonModel extends BaseModel {
Future<void> refresh() async {
if (selectedIndex == 1) return;
await _delivered.refresh(onFinished: () {
await _delivered?.refresh(onFinished: () {
notifyListeners();
});
}
@@ -207,69 +208,62 @@ class CartonModel extends BaseModel {
@override
logout() async {
if (listener != null) await listener.cancel();
if (cartonListener != null) await cartonListener.cancel();
if (_delivered != null) _delivered.close();
if (listener != null) await listener!.cancel();
if (cartonListener != null) await cartonListener!.cancel();
if (_delivered != null) _delivered!.close();
if (cartonsByFilter != null) cartonsByFilter.close();
_boxes = [];
}
Future<List<Carton>> getCartons(String shipmentID) async {
String path = "/$cartons_collection";
var querySnap = await Firestore.instance
var querySnap = await FirebaseFirestore.instance
.collection(path)
.where("shipment_id", isEqualTo: shipmentID)
.getDocuments();
return querySnap.documents
.map((e) => Carton.fromMap(e.data, e.documentID))
.toList();
.get();
return querySnap.docs.map((e) => Carton.fromMap(e.data(), e.id)).toList();
}
Future<List<Carton>> getCartonsByFcsShipment(String fcsShipmentID) async {
String path = "/$cartons_collection";
var querySnap = await Firestore.instance
var querySnap = await FirebaseFirestore.instance
.collection(path)
.where("fcs_shipment_id", isEqualTo: fcsShipmentID)
.where("is_deleted", isEqualTo: false)
.getDocuments();
return querySnap.documents
.map((e) => Carton.fromMap(e.data, e.documentID))
.toList();
.get();
return querySnap.docs.map((e) => Carton.fromMap(e.data(), e.id)).toList();
}
Future<List<Carton>> getCartonsForInvoice(
String fcsShipmentID, String userID) async {
String path = "/$cartons_collection";
var querySnap = await Firestore.instance
var querySnap = await FirebaseFirestore.instance
.collection(path)
.where("fcs_shipment_id", isEqualTo: fcsShipmentID)
.where("user_id", isEqualTo: userID)
.where("is_deleted", isEqualTo: false)
.where("is_invoiced", isEqualTo: false)
.getDocuments();
List<Carton> cartons = querySnap.documents
.map((e) => Carton.fromMap(e.data, e.documentID))
.toList();
.get();
List<Carton> cartons =
querySnap.docs.map((e) => Carton.fromMap(e.data(), e.id)).toList();
return cartons;
}
Future<List<Carton>> getMixCartonsByFcsShipment(String fcsShipmentID) async {
String path = "/$cartons_collection";
var querySnap = await Firestore.instance
var querySnap = await FirebaseFirestore.instance
.collection(path)
.where("fcs_shipment_id", isEqualTo: fcsShipmentID)
.where("carton_type", isEqualTo: carton_mix_box)
.where("is_deleted", isEqualTo: false)
.getDocuments();
return querySnap.documents
.map((e) => Carton.fromMap(e.data, e.documentID))
.toList();
.get();
return querySnap.docs.map((e) => Carton.fromMap(e.data(), e.id)).toList();
}
Future<Carton> getCarton(String id) async {
String path = "/$cartons_collection";
var snap = await Firestore.instance.collection(path).document(id).get();
return Carton.fromMap(snap.data, snap.documentID);
var snap = await FirebaseFirestore.instance.collection(path).doc(id).get();
return Carton.fromMap(snap.data() as Map<String, dynamic>, snap.id);
}
Future<Carton> createCarton(Carton carton) {

View File

@@ -8,12 +8,9 @@ import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/carton_size/carton_size_list.dart';
import 'package:fcs/pages/carton_size/model/carton_size_model.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/length_picker.dart';
import 'package:fcs/pages/widgets/local_button.dart';
import 'package:fcs/pages/widgets/local_text.dart';
@@ -45,7 +42,7 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
Carton? _carton;
bool _isLoading = false;
DeliveryAddress _deliveryAddress = new DeliveryAddress();
DeliveryAddress? _deliveryAddress = new DeliveryAddress();
List<CargoType> _cargoTypes = [];
CartonSize? selectedCatonSize;
bool isFromPackages = false;
@@ -263,7 +260,7 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
.map<DropdownMenuItem<CartonSize>>((CartonSize value) {
return DropdownMenuItem<CartonSize>(
value: value,
child: Text(value.name,
child: Text(value.name ?? "",
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: value.name == MANAGE_CARTONSIZE
@@ -354,7 +351,7 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
Navigator.pop(context, _c);
} else {
await cartonModel.updateCarton(carton);
Carton _c = await cartonModel.getCarton(_carton!.id);
Carton _c = await cartonModel.getCarton(_carton!.id!);
Navigator.pop(context, _c);
}
} catch (e) {

View File

@@ -17,7 +17,7 @@ Widget getCartonNumberStatus(BuildContext context, Carton carton) {
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Chip(label: Text(carton.status)),
child: Chip(label: Text(carton.status??"")),
),
],
);