null safety
This commit is contained in:
@@ -6,10 +6,10 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CargoTable extends StatefulWidget {
|
||||
final List<CargoType> cargoTypes;
|
||||
final List<CargoType>? cargoTypes;
|
||||
|
||||
const CargoTable({
|
||||
Key key,
|
||||
Key? key,
|
||||
this.cargoTypes,
|
||||
}) : super(key: key);
|
||||
|
||||
@@ -58,13 +58,13 @@ class _CargoTableState extends State<CargoTable> {
|
||||
return [];
|
||||
}
|
||||
double total = 0;
|
||||
var rows = widget.cargoTypes.map((c) {
|
||||
total += c.weight;
|
||||
var rows = widget.cargoTypes!.map((c) {
|
||||
total += c.weight!;
|
||||
return MyDataRow(
|
||||
onSelectChanged: (bool selected) async {},
|
||||
cells: [
|
||||
MyDataCell(new Text(
|
||||
c.name == null ? "" : c.name,
|
||||
c.name ?? "",
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(c.qty == null || c.qty == 0
|
||||
@@ -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),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -35,7 +35,7 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
||||
p.isChecked = false;
|
||||
p.isCutomDuty = false;
|
||||
p.weight = 0;
|
||||
p.qty = null;
|
||||
p.qty = 0;
|
||||
});
|
||||
specialCargos.forEach((p) {
|
||||
p.isChecked = false;
|
||||
@@ -61,7 +61,7 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
c.isChecked = !c.isChecked;
|
||||
c.isChecked = !c.isChecked!;
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
@@ -69,12 +69,12 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
||||
Checkbox(
|
||||
value: c.isChecked,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (bool check) {
|
||||
onChanged: (bool? check) {
|
||||
setState(() {
|
||||
c.isChecked = check;
|
||||
});
|
||||
}),
|
||||
new Text(c.name, style: textStyle),
|
||||
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);
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class CargoTypeEditor extends StatefulWidget {
|
||||
final CargoType cargo;
|
||||
final CargoType? cargo;
|
||||
CargoTypeEditor({this.cargo});
|
||||
|
||||
@override
|
||||
@@ -23,14 +23,14 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
||||
TextEditingController _weightController = new TextEditingController();
|
||||
|
||||
bool _isLoading = false;
|
||||
CargoType _cargo;
|
||||
CargoType? _cargo;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.cargo != null) {
|
||||
_cargo = widget.cargo;
|
||||
_weightController.text = _cargo.weight.toStringAsFixed(2);
|
||||
_weightController.text = _cargo!.weight!.toStringAsFixed(2);
|
||||
} else {
|
||||
_loadDefalut();
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
||||
},
|
||||
labelKey: "cargo.type",
|
||||
iconData: Icons.text_format,
|
||||
selectedValue: _cargo,
|
||||
selectedValue: _cargo!,
|
||||
values: cargos,
|
||||
);
|
||||
|
||||
@@ -75,7 +75,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
|
||||
context,
|
||||
getLocalString(context, 'box.cargo.save.btn'),
|
||||
callack: () {
|
||||
_cargo.weight = double.tryParse(_weightController.text) ?? 0;
|
||||
_cargo!.weight = double.tryParse(_weightController.text) ?? 0;
|
||||
Navigator.pop(context, _cargo);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -11,13 +11,13 @@ typedef OnRemove(CargoType cargoType);
|
||||
typedef OnUpdate(CargoType cargoType);
|
||||
|
||||
class CargoTable extends StatefulWidget {
|
||||
final List<CargoType> cargoTypes;
|
||||
final bool isNew;
|
||||
final OnRemove onRemove;
|
||||
final OnUpdate onUpdate;
|
||||
final List<CargoType>? cargoTypes;
|
||||
final bool? isNew;
|
||||
final OnRemove? onRemove;
|
||||
final OnUpdate? onUpdate;
|
||||
|
||||
const CargoTable(
|
||||
{Key key, this.cargoTypes, this.isNew, this.onRemove, this.onUpdate})
|
||||
{Key? key, this.cargoTypes, this.isNew, this.onRemove, this.onUpdate})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -26,14 +26,14 @@ class CargoTable extends StatefulWidget {
|
||||
|
||||
class _CargoTableState extends State<CargoTable> {
|
||||
double totalWeight = 0;
|
||||
List<CargoType> cargoTypes;
|
||||
List<CargoType>? cargoTypes;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
cargoTypes = widget.cargoTypes;
|
||||
if (!widget.isNew) {
|
||||
if (!widget.isNew!) {
|
||||
totalWeight =
|
||||
cargoTypes.fold(0, (previous, current) => previous + current.weight);
|
||||
cargoTypes!.fold(0, (previous, current) => previous + current.weight!);
|
||||
}
|
||||
|
||||
super.initState();
|
||||
@@ -41,7 +41,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print("Cargotypes:${cargoTypes.length}");
|
||||
print("Cargotypes:${cargoTypes!.length}");
|
||||
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
@@ -80,18 +80,18 @@ class _CargoTableState extends State<CargoTable> {
|
||||
if (cargoTypes == null) {
|
||||
return [];
|
||||
}
|
||||
var rows = cargoTypes.map((c) {
|
||||
var rows = cargoTypes!.map((c) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (bool selected) async {},
|
||||
cells: [
|
||||
MyDataCell(
|
||||
new Text(
|
||||
c.name == null ? "" : c.name,
|
||||
c.name ??'',
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
MyDataCell(
|
||||
c.isCutomDuty
|
||||
c.isCutomDuty!
|
||||
? GestureDetector(
|
||||
onTap: () async {
|
||||
String _t = await showDialog(
|
||||
@@ -103,7 +103,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
setState(() {
|
||||
c.qty = int.tryParse(_t) ?? 0;
|
||||
});
|
||||
if (widget.onUpdate != null) widget.onUpdate(c);
|
||||
if (widget.onUpdate != null) widget.onUpdate!(c);
|
||||
},
|
||||
child: Center(
|
||||
child: Container(
|
||||
@@ -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(() {
|
||||
@@ -153,7 +153,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
if (c.weight != 0) {
|
||||
_cal();
|
||||
}
|
||||
if (widget.onUpdate != null) widget.onUpdate(c);
|
||||
if (widget.onUpdate != null) widget.onUpdate!(c);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(7.0),
|
||||
@@ -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),
|
||||
),
|
||||
),
|
||||
@@ -176,7 +176,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
if (widget.onRemove != null) widget.onRemove(c);
|
||||
if (widget.onRemove != null) widget.onRemove!(c);
|
||||
})
|
||||
],
|
||||
),
|
||||
@@ -237,21 +237,21 @@ class _CargoTableState extends State<CargoTable> {
|
||||
}
|
||||
|
||||
_cal() {
|
||||
var cargoType = autoCalWeight(cargoTypes, totalWeight);
|
||||
var cargoType = autoCalWeight(cargoTypes!, totalWeight);
|
||||
if (cargoType == null) return;
|
||||
|
||||
setState(() {
|
||||
cargoTypes.remove(cargoType);
|
||||
cargoTypes.add(cargoType);
|
||||
cargoTypes!.remove(cargoType);
|
||||
cargoTypes!.add(cargoType);
|
||||
});
|
||||
|
||||
if (widget.onUpdate != null) {
|
||||
widget.onUpdate(cargoType);
|
||||
widget.onUpdate!(cargoType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CargoType autoCalWeight(List<CargoType> cargoTypes, double total) {
|
||||
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;
|
||||
|
||||
@@ -13,11 +13,11 @@ typedef OnAdd(CargoType cargoType);
|
||||
typedef OnRemove(CargoType cargoType);
|
||||
|
||||
class CargoTable extends StatefulWidget {
|
||||
final List<CargoType> cargoTypes;
|
||||
final OnAdd onAdd;
|
||||
final OnRemove onRemove;
|
||||
final List<CargoType>? cargoTypes;
|
||||
final OnAdd? onAdd;
|
||||
final OnRemove? onRemove;
|
||||
|
||||
const CargoTable({Key key, this.cargoTypes, this.onAdd, this.onRemove})
|
||||
const CargoTable({Key? key, this.cargoTypes, this.onAdd, this.onRemove})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -67,15 +67,15 @@ class _CargoTableState extends State<CargoTable> {
|
||||
List<String> _types = [];
|
||||
double _total = 0;
|
||||
|
||||
var rows = widget.cargoTypes.map((c) {
|
||||
_total += c.weight;
|
||||
var rows = widget.cargoTypes!.map((c) {
|
||||
_total += c.weight!;
|
||||
return MyDataRow(
|
||||
onSelectChanged: (bool selected) async {},
|
||||
cells: [
|
||||
MyDataCell(Row(
|
||||
children: [
|
||||
new Text(
|
||||
c.name == null ? "" : c.name,
|
||||
c.name ?? "",
|
||||
style: textStyle,
|
||||
),
|
||||
new Text(
|
||||
@@ -88,7 +88,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,
|
||||
@@ -99,7 +99,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
if (widget.onRemove != null) widget.onRemove(c);
|
||||
if (widget.onRemove != null) widget.onRemove!(c);
|
||||
})
|
||||
],
|
||||
),
|
||||
@@ -127,7 +127,7 @@ class _CargoTableState extends State<CargoTable> {
|
||||
alignment: Alignment.centerRight,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
double _t = await Navigator.of(context).push<double>(
|
||||
double? _t = await Navigator.of(context).push<double>(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
TotalWeightEdit(totalWeight: totalWeight)));
|
||||
@@ -135,21 +135,21 @@ class _CargoTableState extends State<CargoTable> {
|
||||
setState(() {
|
||||
totalWeight = _t;
|
||||
this.remainingWeight = this.totalWeight - _total;
|
||||
widget.cargoTypes.forEach((c) {
|
||||
widget.cargoTypes!.forEach((c) {
|
||||
if (c.qty == null) {
|
||||
this._cargos.add(c);
|
||||
}
|
||||
});
|
||||
this._cargos.forEach((c) {
|
||||
_list.add(c.name);
|
||||
_list.add(c.name!);
|
||||
});
|
||||
widget.cargoTypes.forEach((c) {
|
||||
_types.add(c.name);
|
||||
widget.cargoTypes!.forEach((c) {
|
||||
_types.add(c.name!);
|
||||
});
|
||||
if (this._cargos.length == widget.cargoTypes.length - 1) {
|
||||
if (this._cargos.length == widget.cargoTypes!.length - 1) {
|
||||
_types.forEach((t) {
|
||||
if (!_list.contains(t)) {
|
||||
widget.cargoTypes.forEach((c) {
|
||||
widget.cargoTypes!.forEach((c) {
|
||||
if (c.name == t) {
|
||||
c.weight = this.remainingWeight;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import 'package:fcs/pages/widgets/local_title.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:provider/provider.dart';
|
||||
import 'cargo_type_addtion.dart';
|
||||
import 'carton_cargo_table.dart';
|
||||
@@ -40,7 +40,7 @@ import 'package_carton_editor.dart';
|
||||
import 'widgets.dart';
|
||||
|
||||
class CartonEditor extends StatefulWidget {
|
||||
final Carton box;
|
||||
final Carton? box;
|
||||
CartonEditor({this.box});
|
||||
|
||||
@override
|
||||
@@ -54,29 +54,29 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||
List<CargoType> _cargoTypes = [];
|
||||
|
||||
Carton _carton;
|
||||
Carton? _carton;
|
||||
bool _isLoading = false;
|
||||
bool _isNew;
|
||||
User _user;
|
||||
String _selectedCartonType;
|
||||
bool _isNew = false;
|
||||
User? _user;
|
||||
String? _selectedCartonType;
|
||||
|
||||
double volumetricRatio = 0;
|
||||
double shipmentWeight = 0;
|
||||
FcsShipment _fcsShipment;
|
||||
List<FcsShipment> _fcsShipments;
|
||||
FcsShipment? _fcsShipment;
|
||||
List<FcsShipment>? _fcsShipments;
|
||||
List<Carton> _cartons = [];
|
||||
CartonSize selectedCatonSize;
|
||||
CartonSize? selectedCatonSize;
|
||||
|
||||
//for mix carton
|
||||
List<Carton> _mixCartons = [];
|
||||
String _selectedMixBoxType;
|
||||
String? _selectedMixBoxType;
|
||||
|
||||
//for carton from cargos
|
||||
User consignee;
|
||||
User sender;
|
||||
User? consignee;
|
||||
User? sender;
|
||||
List<Carton> _cartonsFromCartons = [];
|
||||
|
||||
double totalWeight;
|
||||
double? totalWeight;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -92,28 +92,28 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
|
||||
if (widget.box != null) {
|
||||
_carton = widget.box;
|
||||
_deliveryAddress = _carton.deliveryAddress;
|
||||
_widthController.text = _carton.width.toString();
|
||||
_heightController.text = _carton.height.toString();
|
||||
_lengthController.text = _carton.length.toString();
|
||||
_selectedCartonType = _carton.cartonType;
|
||||
_deliveryAddress = _carton!.deliveryAddress;
|
||||
_widthController.text = _carton!.width.toString();
|
||||
_heightController.text = _carton!.height.toString();
|
||||
_lengthController.text = _carton!.length.toString();
|
||||
_selectedCartonType = _carton!.cartonType;
|
||||
|
||||
_cargoTypes = _carton.cargoTypes.map((e) => e.clone()).toList();
|
||||
_cargoTypes = _carton!.cargoTypes.map((e) => e.clone()).toList();
|
||||
|
||||
_isNew = false;
|
||||
_user = User(
|
||||
id: _carton.userID, fcsID: _carton.fcsID, name: _carton.userName);
|
||||
id: _carton!.userID, fcsID: _carton!.fcsID, name: _carton!.userName);
|
||||
consignee = User(
|
||||
id: _carton.userID, fcsID: _carton.fcsID, name: _carton.userName);
|
||||
id: _carton!.userID, fcsID: _carton!.fcsID, name: _carton!.userName);
|
||||
sender = User(
|
||||
id: _carton.senderID,
|
||||
fcsID: _carton.senderFCSID,
|
||||
name: _carton.senderName);
|
||||
_selectedMixBoxType = _carton.mixBoxType ?? "";
|
||||
id: _carton!.senderID,
|
||||
fcsID: _carton!.senderFCSID,
|
||||
name: _carton!.senderName);
|
||||
_selectedMixBoxType = _carton!.mixBoxType;
|
||||
this._mixCartons =
|
||||
_carton.mixCartons == null ? [] : List.from(_carton.mixCartons);
|
||||
bool isMixBox = _carton.cartonType == carton_mix_box;
|
||||
bool isFromPackages = _carton.cartonType == carton_from_packages;
|
||||
_carton!.mixCartons == null ? [] : List.from(_carton!.mixCartons);
|
||||
bool isMixBox = _carton!.cartonType == carton_mix_box;
|
||||
bool isFromPackages = _carton!.cartonType == carton_from_packages;
|
||||
if (isFromPackages) _loadPackages();
|
||||
|
||||
if (!isMixBox) {
|
||||
@@ -138,8 +138,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
FcsShipmentModel fcsShipmentModel =
|
||||
Provider.of<FcsShipmentModel>(context, listen: false);
|
||||
var fcsShipments = await fcsShipmentModel.getActiveFcsShipments();
|
||||
var fcsShipment = fcsShipments
|
||||
.firstWhere((e) => e.id == _carton.fcsShipmentID, orElse: () => null);
|
||||
var fcsShipment =
|
||||
fcsShipments.firstWhere((e) => e.id == _carton!.fcsShipmentID);
|
||||
setState(() {
|
||||
_fcsShipments = fcsShipments;
|
||||
_fcsShipment = fcsShipment;
|
||||
@@ -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;
|
||||
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 {
|
||||
@@ -169,8 +169,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
});
|
||||
} else {
|
||||
packages.forEach((p) {
|
||||
if (_carton.packages.contains(p)) {
|
||||
p.isChecked = _carton.packages.firstWhere((cp) => cp == p).isChecked;
|
||||
if (_carton!.packages.contains(p)) {
|
||||
p.isChecked = _carton!.packages.firstWhere((cp) => cp == p).isChecked;
|
||||
} else {
|
||||
p.isChecked = false;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_carton.packages = packages;
|
||||
_carton!.packages = packages;
|
||||
});
|
||||
// _populateDeliveryAddress();
|
||||
}
|
||||
@@ -206,9 +206,9 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_getCartonSize() {
|
||||
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
||||
cartonSizeModel.cartonSizes.forEach((c) {
|
||||
if (c.length == _carton.length &&
|
||||
c.width == _carton.width &&
|
||||
c.height == _carton.height) {
|
||||
if (c.length == _carton!.length &&
|
||||
c.width == _carton!.width &&
|
||||
c.height == _carton!.height) {
|
||||
selectedCatonSize = CartonSize(
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
@@ -232,7 +232,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
bool isMixBox = _selectedCartonType == carton_mix_box;
|
||||
|
||||
final shipmentBox = DisplayText(
|
||||
text: _carton.fcsShipmentNumber,
|
||||
text: _carton!.fcsShipmentNumber,
|
||||
labelTextKey: "box.fcs_shipment_num",
|
||||
iconData: Ionicons.ios_airplane,
|
||||
);
|
||||
@@ -248,8 +248,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
labelKey: "shipment.pack.fcs.shipment",
|
||||
iconData: Ionicons.ios_airplane,
|
||||
display: (u) => u.shipmentNumber,
|
||||
selectedValue: _fcsShipment,
|
||||
values: _fcsShipments,
|
||||
selectedValue: _fcsShipment!,
|
||||
values: _fcsShipments!,
|
||||
));
|
||||
|
||||
final fcsIDBox = Container(
|
||||
@@ -297,7 +297,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
readOnly: !_isNew,
|
||||
values: boxModel.cartonTypes,
|
||||
selectedValue: _selectedCartonType,
|
||||
callback: (v) {
|
||||
callback: (String? v) {
|
||||
setState(() {
|
||||
_selectedCartonType = v;
|
||||
});
|
||||
@@ -337,7 +337,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
value: e,
|
||||
groupValue: _selectedMixBoxType,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (v) {
|
||||
onChanged: (String? v) {
|
||||
setState(() {
|
||||
_selectedMixBoxType = v;
|
||||
});
|
||||
@@ -407,7 +407,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
List<CargoType> cargos = await Navigator.push<List<CargoType>>(
|
||||
List<CargoType>? cargos = await Navigator.push<List<CargoType>>(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
||||
if (cargos == null) return;
|
||||
@@ -462,7 +462,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: DisplayText(
|
||||
text: consignee != null ? consignee.fcsID : "",
|
||||
text: consignee != null ? consignee!.fcsID : "",
|
||||
labelTextKey: "processing.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
)),
|
||||
@@ -477,7 +477,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
);
|
||||
|
||||
final consigneeNameBox = DisplayText(
|
||||
text: consignee != null ? consignee.name : "",
|
||||
text: consignee != null ? consignee!.name : "",
|
||||
labelTextKey: "processing.consignee.name",
|
||||
maxLines: 2,
|
||||
iconData: Icons.person,
|
||||
@@ -496,7 +496,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: DisplayText(
|
||||
text: sender != null ? sender.fcsID : "",
|
||||
text: sender != null ? sender!.fcsID : "",
|
||||
labelTextKey: "processing.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
)),
|
||||
@@ -511,7 +511,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
);
|
||||
|
||||
final shipperNamebox = DisplayText(
|
||||
text: sender != null ? sender.name : "",
|
||||
text: sender != null ? sender!.name : "",
|
||||
labelTextKey: "processing.shipper.name",
|
||||
maxLines: 2,
|
||||
iconData: Icons.person,
|
||||
@@ -551,7 +551,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
children: [
|
||||
_isNew
|
||||
? Container()
|
||||
: Center(child: getCartonNumberStatus(context, _carton)),
|
||||
: Center(child: getCartonNumberStatus(context, _carton!)),
|
||||
LocalTitle(textKey: "box.type.title"),
|
||||
cartonTypeBox,
|
||||
LocalTitle(textKey: "box.shipment_info"),
|
||||
@@ -572,7 +572,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
isFromPackages ? namebox : Container(),
|
||||
isFromPackages
|
||||
? CartonPackageTable(
|
||||
packages: _carton.packages,
|
||||
packages: _carton!.packages,
|
||||
onSelect: (p, checked) {
|
||||
// if (checked &&
|
||||
// _deliveryAddress != null &&
|
||||
@@ -623,7 +623,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
deliveryAddress: _deliveryAddress,
|
||||
labelKey: "box.delivery_address",
|
||||
onTap: () async {
|
||||
DeliveryAddress d =
|
||||
DeliveryAddress? d =
|
||||
await Navigator.push<DeliveryAddress>(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
@@ -631,8 +631,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
DeliveryAddressSelection(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
user: User(
|
||||
id: _carton.userID,
|
||||
name: _carton.userName))),
|
||||
id: _carton!.userID,
|
||||
name: _carton!.userName))),
|
||||
);
|
||||
if (d == null) return;
|
||||
setState(() {
|
||||
@@ -667,7 +667,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
||||
if (isFromPackages) {
|
||||
_loadPackages();
|
||||
c.value.packages = _carton.packages;
|
||||
c.value.packages = _carton!.packages;
|
||||
Carton _c = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
@@ -736,20 +736,20 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
height: 1,
|
||||
color: Colors.grey,
|
||||
),
|
||||
onChanged: (CartonSize newValue) {
|
||||
onChanged: (CartonSize? newValue) {
|
||||
setState(() {
|
||||
if (newValue.name == MANAGE_CARTONSIZE) {
|
||||
if (newValue!.name == MANAGE_CARTONSIZE) {
|
||||
selectedCatonSize = null;
|
||||
_manageCartonSize();
|
||||
return;
|
||||
}
|
||||
selectedCatonSize = newValue;
|
||||
_widthController.text =
|
||||
selectedCatonSize.width.toString();
|
||||
selectedCatonSize!.width.toString();
|
||||
_heightController.text =
|
||||
selectedCatonSize.height.toString();
|
||||
selectedCatonSize!.height.toString();
|
||||
_lengthController.text =
|
||||
selectedCatonSize.length.toString();
|
||||
selectedCatonSize!.length.toString();
|
||||
});
|
||||
},
|
||||
isExpanded: true,
|
||||
@@ -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
|
||||
@@ -789,8 +789,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
|
||||
_updateCargo(CargoType cargo) {
|
||||
setState(() {
|
||||
var _c =
|
||||
_cargoTypes.firstWhere((e) => e.id == cargo.id, orElse: () => null);
|
||||
var _c = _cargoTypes.firstWhere((e) => e.id == cargo.id);
|
||||
if (_c != null) {
|
||||
_c.weight = cargo.weight;
|
||||
_c.qty = cargo.qty;
|
||||
@@ -827,30 +826,30 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
double h = double.parse(_heightController.text, (s) => 0);
|
||||
|
||||
Carton carton = Carton();
|
||||
carton.id = _carton.id;
|
||||
carton.cartonType = _selectedCartonType;
|
||||
carton.fcsShipmentID = _isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
||||
carton.id = _carton!.id;
|
||||
carton.cartonType = _selectedCartonType!;
|
||||
carton.fcsShipmentID = _isNew ? _fcsShipment!.id : _carton!.fcsShipmentID;
|
||||
if (isFromPackages) {
|
||||
carton.userID = _user?.id;
|
||||
carton.fcsID = _user?.fcsID;
|
||||
carton.userName = _user?.name;
|
||||
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
|
||||
carton.userID = _user?.id ?? '';
|
||||
carton.fcsID = _user?.fcsID ?? '';
|
||||
carton.userName = _user?.name ?? '';
|
||||
carton.packages = _carton!.packages.where((e) => e.isChecked).toList();
|
||||
}
|
||||
|
||||
if (isFromCartons) {
|
||||
carton.userID = consignee?.id;
|
||||
carton.fcsID = consignee?.fcsID;
|
||||
carton.userName = consignee?.name;
|
||||
carton.senderID = sender?.id;
|
||||
carton.senderFCSID = sender?.fcsID;
|
||||
carton.senderName = sender?.name;
|
||||
carton.userID = consignee?.id ?? "";
|
||||
carton.fcsID = consignee?.fcsID ?? "";
|
||||
carton.userName = consignee?.name ?? "";
|
||||
carton.senderID = sender?.id ?? "";
|
||||
carton.senderFCSID = sender?.fcsID ?? "";
|
||||
carton.senderName = sender?.name ?? "";
|
||||
}
|
||||
|
||||
carton.cargoTypes = _carton.cargoTypes;
|
||||
carton.cargoTypes = _carton!.cargoTypes;
|
||||
carton.length = l;
|
||||
carton.width = w;
|
||||
carton.height = h;
|
||||
carton.deliveryAddress = _carton.deliveryAddress;
|
||||
carton.deliveryAddress = _carton!.deliveryAddress;
|
||||
|
||||
try {
|
||||
Carton _c = await Navigator.push(
|
||||
@@ -898,15 +897,15 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
showMsgDialog(context, "Error", "Please select FCS shipment");
|
||||
return;
|
||||
}
|
||||
if ((this._mixCartons?.length ?? 0) == 0) {
|
||||
if (this._mixCartons.length == 0) {
|
||||
showMsgDialog(context, "Error", "Expect at least one carton");
|
||||
return;
|
||||
}
|
||||
Carton carton = Carton();
|
||||
carton.id = _carton.id;
|
||||
carton.cartonType = _selectedCartonType;
|
||||
carton.fcsShipmentID = _isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
||||
carton.mixBoxType = _selectedMixBoxType;
|
||||
carton.id = _carton!.id;
|
||||
carton.cartonType = _selectedCartonType!;
|
||||
carton.fcsShipmentID = _isNew ? _fcsShipment!.id : _carton!.fcsShipmentID;
|
||||
carton.mixBoxType = _selectedMixBoxType!;
|
||||
carton.mixCartons = this._mixCartons;
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
@@ -932,11 +931,11 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_save() async {
|
||||
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
||||
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
||||
if ((_cargoTypes?.length ?? 0) == 0 && (isFromPackages || isFromCartons)) {
|
||||
if (_cargoTypes.length == 0 && (isFromPackages || isFromCartons)) {
|
||||
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;
|
||||
}
|
||||
@@ -953,16 +952,16 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
}
|
||||
|
||||
Carton carton = Carton();
|
||||
carton.id = _carton.id;
|
||||
carton.cartonType = _selectedCartonType;
|
||||
carton.fcsShipmentID = _isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
||||
carton.id = _carton!.id;
|
||||
carton.cartonType = _selectedCartonType!;
|
||||
carton.fcsShipmentID = _isNew ? _fcsShipment!.id : _carton!.fcsShipmentID;
|
||||
if (isFromPackages) {
|
||||
carton.userID = _user?.id;
|
||||
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
|
||||
carton.userID = _user?.id ?? "";
|
||||
carton.packages = _carton!.packages.where((e) => e.isChecked).toList();
|
||||
}
|
||||
if (isFromCartons) {
|
||||
carton.userID = consignee?.id;
|
||||
carton.senderID = sender?.id;
|
||||
carton.userID = consignee?.id ?? "";
|
||||
carton.senderID = sender?.id ?? "";
|
||||
}
|
||||
|
||||
carton.cargoTypes = _cargoTypes;
|
||||
|
||||
@@ -19,7 +19,7 @@ import 'package:fcs/pages/widgets/local_title.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:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -33,7 +33,7 @@ import 'widgets.dart';
|
||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||
|
||||
class CartonInfo extends StatefulWidget {
|
||||
final Carton box;
|
||||
final Carton? box;
|
||||
CartonInfo({this.box});
|
||||
|
||||
@override
|
||||
@@ -42,7 +42,7 @@ class CartonInfo extends StatefulWidget {
|
||||
|
||||
class _CartonInfoState extends State<CartonInfo> {
|
||||
bool _isLoading = false;
|
||||
Carton _box;
|
||||
Carton? _box;
|
||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||
TextEditingController _widthController = new TextEditingController();
|
||||
TextEditingController _heightController = new TextEditingController();
|
||||
@@ -50,14 +50,14 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
TextEditingController _cartonSizeController = new TextEditingController();
|
||||
double volumetricRatio = 0;
|
||||
double shipmentWeight = 0;
|
||||
String selectMixBoxType;
|
||||
String? selectMixBoxType;
|
||||
|
||||
bool isMixBox;
|
||||
bool isFromShipments;
|
||||
bool isFromPackages;
|
||||
bool isSmallBag;
|
||||
bool isFromCartons;
|
||||
bool isEdiable;
|
||||
bool isMixBox = false;
|
||||
bool isFromShipments = false;
|
||||
bool isFromPackages = false;
|
||||
bool isSmallBag = false;
|
||||
bool isFromCartons = false;
|
||||
bool isEdiable = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -77,29 +77,29 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
}
|
||||
|
||||
_updateBoxData() {
|
||||
_widthController.text = _box.width.toString();
|
||||
_heightController.text = _box.height.toString();
|
||||
_lengthController.text = _box.length.toString();
|
||||
_cartonSizeController.text = _box.cartonSizeName ?? "";
|
||||
_deliveryAddress = _box.deliveryAddress;
|
||||
isMixBox = _box.cartonType == carton_mix_box;
|
||||
isFromShipments = _box.cartonType == carton_from_shipments;
|
||||
isFromPackages = _box.cartonType == carton_from_packages;
|
||||
isSmallBag = _box.cartonType == carton_small_bag;
|
||||
isFromCartons = _box.cartonType == carton_from_cartons;
|
||||
_widthController.text = _box!.width.toString();
|
||||
_heightController.text = _box!.height.toString();
|
||||
_lengthController.text = _box!.length.toString();
|
||||
_cartonSizeController.text = _box!.cartonSizeName;
|
||||
_deliveryAddress = _box!.deliveryAddress;
|
||||
isMixBox = _box!.cartonType == carton_mix_box;
|
||||
isFromShipments = _box!.cartonType == carton_from_shipments;
|
||||
isFromPackages = _box!.cartonType == carton_from_packages;
|
||||
isSmallBag = _box!.cartonType == carton_small_bag;
|
||||
isFromCartons = _box!.cartonType == carton_from_cartons;
|
||||
|
||||
isEdiable = (isFromPackages || isMixBox || isFromCartons) &&
|
||||
_box.status == carton_packed_status;
|
||||
selectMixBoxType = _box.mixBoxType ?? "";
|
||||
_box!.status == carton_packed_status;
|
||||
selectMixBoxType = _box!.mixBoxType;
|
||||
getCartonSize();
|
||||
}
|
||||
|
||||
getCartonSize() {
|
||||
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
||||
cartonSizeModel.cartonSizes.forEach((c) {
|
||||
if (c.length == _box.length &&
|
||||
c.width == _box.width &&
|
||||
c.height == _box.height) {
|
||||
if (c.length == _box!.length &&
|
||||
c.width == _box!.width &&
|
||||
c.height == _box!.height) {
|
||||
setState(() {
|
||||
_cartonSizeController.text = c.name;
|
||||
});
|
||||
@@ -110,36 +110,37 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
_loadPackages() async {
|
||||
if (!isFromPackages && !isSmallBag) return;
|
||||
|
||||
if (_box.cartonType == carton_from_packages && _box.userID == null) return;
|
||||
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,
|
||||
package_delivered_status
|
||||
]);
|
||||
packages = packages.where((p) => _box.packageIDs.contains(p.id)).toList();
|
||||
packages = packages.where((p) => _box!.packageIDs.contains(p.id)).toList();
|
||||
packages.forEach((p) {
|
||||
p.isChecked = true;
|
||||
});
|
||||
|
||||
setState(() {
|
||||
_box.packages = packages;
|
||||
_box!.packages = packages;
|
||||
});
|
||||
}
|
||||
|
||||
_loadMixCartons() async {
|
||||
if (_box.cartonType != carton_mix_box) return;
|
||||
if (_box!.cartonType != carton_mix_box) return;
|
||||
CartonModel cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||
List<Carton> catons = [];
|
||||
for (var id in _box.mixCartonIDs) {
|
||||
for (var id in _box!.mixCartonIDs) {
|
||||
Carton c = await cartonModel.getCarton(id);
|
||||
catons.add(c);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_box.mixCartons = catons;
|
||||
_box!.mixCartons = catons;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -167,32 +168,32 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
readOnly: true,
|
||||
values: cartonModel.cartonTypesInfo,
|
||||
selectedValue:
|
||||
_box.isShipmentCarton ? carton_from_shipments : _box.cartonType);
|
||||
_box!.isShipmentCarton ? carton_from_shipments : _box!.cartonType);
|
||||
final shipmentBox = DisplayText(
|
||||
text: _box.fcsShipmentNumber,
|
||||
text: _box!.fcsShipmentNumber,
|
||||
labelTextKey: "box.fcs_shipment_num",
|
||||
iconData: Ionicons.ios_airplane,
|
||||
);
|
||||
final fcsIDBox = DisplayText(
|
||||
text: _box.fcsID == null ? "" : _box.fcsID,
|
||||
text: _box!.fcsID == null ? "" : _box!.fcsID,
|
||||
labelTextKey: "box.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
);
|
||||
|
||||
final customerNameBox = DisplayText(
|
||||
text: _box.userName == null ? "" : _box.userName,
|
||||
text: _box!.userName == null ? "" : _box!.userName,
|
||||
labelTextKey: "box.name",
|
||||
iconData: Icons.person,
|
||||
);
|
||||
|
||||
final consigneefcsIDBox = DisplayText(
|
||||
text: _box.fcsID != null ? _box.fcsID : "",
|
||||
text: _box!.fcsID != null ? _box!.fcsID : "",
|
||||
labelTextKey: "processing.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
);
|
||||
|
||||
final consigneeNameBox = DisplayText(
|
||||
text: _box.userName != null ? _box.userName : "",
|
||||
text: _box!.userName != null ? _box!.userName : "",
|
||||
labelTextKey: "processing.consignee.name",
|
||||
maxLines: 2,
|
||||
iconData: Icons.person,
|
||||
@@ -211,7 +212,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: DisplayText(
|
||||
text: _box.senderFCSID != null ? _box.senderFCSID : "",
|
||||
text: _box!.senderFCSID,
|
||||
labelTextKey: "processing.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
)),
|
||||
@@ -219,7 +220,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
);
|
||||
|
||||
final shipperNamebox = DisplayText(
|
||||
text: _box.senderName != null ? _box.senderName : "",
|
||||
text: _box!.senderName,
|
||||
labelTextKey: "processing.shipper.name",
|
||||
maxLines: 2,
|
||||
iconData: Icons.person,
|
||||
@@ -269,10 +270,10 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
iconData: AntDesign.CodeSandbox,
|
||||
);
|
||||
final cargoTableBox = CargoTable(
|
||||
cargoTypes: _box.cargoTypes,
|
||||
cargoTypes: _box!.cargoTypes,
|
||||
);
|
||||
final mixCartonNumberBox = DisplayText(
|
||||
text: _box.mixCartonNumber,
|
||||
text: _box!.mixCartonNumber,
|
||||
labelTextKey: "box.mix.carton",
|
||||
iconData: MaterialCommunityIcons.package,
|
||||
);
|
||||
@@ -300,7 +301,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
Text(selectMixBoxType)
|
||||
Text(selectMixBoxType ?? "")
|
||||
],
|
||||
)
|
||||
],
|
||||
@@ -340,7 +341,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: ListView(shrinkWrap: true, children: <Widget>[
|
||||
Center(child: getCartonNumberStatus(context, _box)),
|
||||
Center(child: getCartonNumberStatus(context, _box!)),
|
||||
LocalTitle(textKey: "box.type.title"),
|
||||
cartonTypeBox,
|
||||
LocalTitle(textKey: "box.shipment_info"),
|
||||
@@ -367,11 +368,11 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
isMixBox ? mixTypeBox : Container(),
|
||||
isMixBox ? LocalTitle(textKey: "box.mix_caton_title") : Container(),
|
||||
isMixBox
|
||||
? Column(children: _getCartons(context, _box.mixCartons))
|
||||
? Column(children: _getCartons(context, _box!.mixCartons))
|
||||
: Container(),
|
||||
isFromPackages || isSmallBag
|
||||
? CartonPackageTable(
|
||||
packages: _box.packages,
|
||||
packages: _box!.packages,
|
||||
)
|
||||
: Container(),
|
||||
isMixBox ? Container() : LocalTitle(textKey: "box.cargo.type"),
|
||||
@@ -408,14 +409,14 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
}
|
||||
|
||||
_gotoEditor() async {
|
||||
_box.mixCartons = _box.mixCartons;
|
||||
bool updated = await Navigator.push<bool>(
|
||||
_box!.mixCartons = _box!.mixCartons;
|
||||
bool? updated = await Navigator.push<bool>(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => CartonEditor(box: _box)),
|
||||
);
|
||||
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();
|
||||
@@ -437,7 +438,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
});
|
||||
try {
|
||||
var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||
await cartonModel.deleteCarton(widget.box);
|
||||
await cartonModel.deleteCarton(widget.box!);
|
||||
Navigator.pop(context, true);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
|
||||
@@ -3,13 +3,13 @@ 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 'carton_info.dart';
|
||||
|
||||
class CartonListRow extends StatelessWidget {
|
||||
final Carton box;
|
||||
CartonListRow({Key key, this.box}) : super(key: key);
|
||||
final Carton? box;
|
||||
CartonListRow({Key? key, 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 == null ? "" : 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),
|
||||
),
|
||||
|
||||
@@ -8,10 +8,10 @@ import 'package:flutter/material.dart';
|
||||
typedef OnSelect = Function(Carton carton, bool checked);
|
||||
|
||||
class CartonMixTable extends StatelessWidget {
|
||||
final List<Carton> cartons;
|
||||
final OnSelect onSelect;
|
||||
final List<Carton>? cartons;
|
||||
final OnSelect? onSelect;
|
||||
|
||||
const CartonMixTable({Key key, this.cartons, this.onSelect})
|
||||
const CartonMixTable({Key? key, this.cartons, this.onSelect})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -32,21 +32,21 @@ class CartonMixTable extends StatelessWidget {
|
||||
);
|
||||
|
||||
final rows = cartons == null
|
||||
? []
|
||||
: cartons.asMap().entries.map((p) {
|
||||
? [Container()]
|
||||
: cartons!.asMap().entries.map((p) {
|
||||
return Container(
|
||||
color: p.value.isChecked
|
||||
? Colors.grey.withOpacity(0.2)
|
||||
: Colors.grey[50].withOpacity(0.2),
|
||||
: Colors.grey.shade50.withOpacity(0.2),
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: p.key == cartons.length - 1
|
||||
color: p.key == cartons!.length - 1
|
||||
? Colors.white
|
||||
: Colors.grey[350],
|
||||
: Colors.grey.shade300,
|
||||
width: 1),
|
||||
),
|
||||
),
|
||||
@@ -55,16 +55,16 @@ class CartonMixTable extends StatelessWidget {
|
||||
Checkbox(
|
||||
value: p.value.isChecked,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (bool check) {
|
||||
if (onSelect != null) onSelect(p.value, check);
|
||||
onChanged: (bool? check) {
|
||||
if (onSelect != null) onSelect!(p.value, check!);
|
||||
}),
|
||||
Expanded(
|
||||
child: new Text(
|
||||
p.value.cartonNumber ?? "",
|
||||
p.value.cartonNumber,
|
||||
style: textStyle,
|
||||
)),
|
||||
new Text(
|
||||
p.value?.actualWeight?.toString() ?? "",
|
||||
p.value.actualWeight.toString(),
|
||||
style: textStyle,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -8,10 +8,10 @@ import 'package:flutter/material.dart';
|
||||
typedef OnSelect = Function(Package package, bool checked);
|
||||
|
||||
class CartonPackageTable extends StatelessWidget {
|
||||
final List<Package> packages;
|
||||
final OnSelect onSelect;
|
||||
final List<Package>? packages;
|
||||
final OnSelect? onSelect;
|
||||
|
||||
const CartonPackageTable({Key key, this.packages, this.onSelect})
|
||||
const CartonPackageTable({Key? key, this.packages, this.onSelect})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -34,20 +34,20 @@ class CartonPackageTable extends StatelessWidget {
|
||||
|
||||
final rows = packages == null
|
||||
? [Container()]
|
||||
: packages.asMap().entries.map((p) {
|
||||
: packages!.asMap().entries.map((p) {
|
||||
return Container(
|
||||
color: p.value.isChecked
|
||||
? Colors.grey.withOpacity(0.2)
|
||||
: Colors.grey[50].withOpacity(0.2),
|
||||
: Colors.grey.shade50.withOpacity(0.2),
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: p.key == packages.length - 1
|
||||
color: p.key == packages!.length - 1
|
||||
? Colors.white
|
||||
: Colors.grey[350],
|
||||
: Colors.grey.shade300,
|
||||
width: 1),
|
||||
),
|
||||
),
|
||||
@@ -62,8 +62,8 @@ class CartonPackageTable extends StatelessWidget {
|
||||
: Checkbox(
|
||||
value: p.value.isChecked,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (bool check) {
|
||||
if (onSelect != null) onSelect(p.value, check);
|
||||
onChanged: (bool? check) {
|
||||
if (onSelect != null) onSelect!(p.value, check!);
|
||||
}),
|
||||
Expanded(
|
||||
child: Column(
|
||||
@@ -74,11 +74,11 @@ class CartonPackageTable extends StatelessWidget {
|
||||
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,11 +88,11 @@ class CartonPackageTable extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
new Text(
|
||||
p.value?.desc ?? "",
|
||||
p.value.desc,
|
||||
style: textStyle,
|
||||
),
|
||||
new Text(
|
||||
"(${p.value?.market ?? ""})",
|
||||
"(${p.value.market})",
|
||||
style: textStyle,
|
||||
)
|
||||
],
|
||||
|
||||
@@ -2,15 +2,15 @@ import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/helpers/theme.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';
|
||||
|
||||
typedef OnRemove(Carton carton);
|
||||
|
||||
class CartonRow extends StatelessWidget {
|
||||
final Carton box;
|
||||
final OnRemove onRemove;
|
||||
CartonRow({Key key, this.box, this.onRemove}) : super(key: key);
|
||||
final Carton? box;
|
||||
final OnRemove? onRemove;
|
||||
CartonRow({Key? key, this.box, this.onRemove}) : super(key: key);
|
||||
|
||||
final double dotSize = 15.0;
|
||||
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
||||
@@ -20,7 +20,7 @@ class CartonRow extends StatelessWidget {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey[300]),
|
||||
bottom: BorderSide(color: Colors.grey.shade300),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -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),
|
||||
),
|
||||
|
||||
@@ -3,10 +3,10 @@ import 'package:flutter/material.dart';
|
||||
typedef OnAdd(String value);
|
||||
|
||||
class InputTextBorder extends StatelessWidget {
|
||||
final OnAdd onAdd;
|
||||
final TextEditingController controller;
|
||||
final OnAdd? onAdd;
|
||||
final TextEditingController? controller;
|
||||
|
||||
const InputTextBorder({Key key, this.onAdd, this.controller})
|
||||
const InputTextBorder({Key? key, this.onAdd, this.controller})
|
||||
: super(key: key);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -14,7 +14,7 @@ class InputTextBorder extends StatelessWidget {
|
||||
textAlign: TextAlign.center,
|
||||
controller: controller,
|
||||
onChanged: (v) {
|
||||
if (onAdd != null) onAdd(v);
|
||||
if (onAdd != null) onAdd!(v);
|
||||
},
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: new InputDecoration(
|
||||
|
||||
@@ -21,7 +21,7 @@ import 'package:fcs/pages/widgets/local_title.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:provider/provider.dart';
|
||||
|
||||
import 'cargo_type_addtion.dart';
|
||||
@@ -29,9 +29,9 @@ import 'carton_cargo_table.dart';
|
||||
import 'model/carton_model.dart';
|
||||
|
||||
class PackageCartonEditor extends StatefulWidget {
|
||||
final Carton carton;
|
||||
final bool isNew;
|
||||
final User consignee;
|
||||
final Carton? carton;
|
||||
final bool? isNew;
|
||||
final User? consignee;
|
||||
PackageCartonEditor({this.carton, this.isNew, this.consignee});
|
||||
|
||||
@override
|
||||
@@ -43,13 +43,13 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
TextEditingController _widthCtl = new TextEditingController();
|
||||
TextEditingController _heightCtl = new TextEditingController();
|
||||
|
||||
Carton _carton;
|
||||
Carton? _carton;
|
||||
bool _isLoading = false;
|
||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||
List<CargoType> _cargoTypes = [];
|
||||
CartonSize selectedCatonSize;
|
||||
bool isFromPackages;
|
||||
bool isFromCartons;
|
||||
CartonSize? selectedCatonSize;
|
||||
bool isFromPackages = false;
|
||||
bool isFromCartons = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -59,19 +59,19 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
|
||||
_load() {
|
||||
_carton = widget.carton;
|
||||
isFromPackages = _carton.cartonType == carton_from_packages;
|
||||
isFromCartons = _carton.cartonType == carton_from_cartons;
|
||||
isFromPackages = _carton!.cartonType == carton_from_packages;
|
||||
isFromCartons = _carton!.cartonType == carton_from_cartons;
|
||||
|
||||
if (widget.isNew) {
|
||||
if (widget.isNew!) {
|
||||
_lengthCtl.text = "0";
|
||||
_widthCtl.text = "0";
|
||||
_heightCtl.text = "0";
|
||||
} else {
|
||||
_cargoTypes = widget.carton.cargoTypes.map((e) => e.clone()).toList();
|
||||
_lengthCtl.text = _carton.length.toString();
|
||||
_widthCtl.text = _carton.width.toString();
|
||||
_heightCtl.text = _carton.height.toString();
|
||||
_deliveryAddress = _carton.deliveryAddress;
|
||||
_cargoTypes = widget.carton!.cargoTypes.map((e) => e.clone()).toList();
|
||||
_lengthCtl.text = _carton!.length.toString();
|
||||
_widthCtl.text = _carton!.width.toString();
|
||||
_heightCtl.text = _carton!.height.toString();
|
||||
_deliveryAddress = _carton!.deliveryAddress;
|
||||
_getCartonSize();
|
||||
}
|
||||
}
|
||||
@@ -79,9 +79,9 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
_getCartonSize() {
|
||||
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
||||
cartonSizeModel.cartonSizes.forEach((c) {
|
||||
if (c.length == _carton.length &&
|
||||
c.width == _carton.width &&
|
||||
c.height == _carton.height) {
|
||||
if (c.length == _carton!.length &&
|
||||
c.width == _carton!.width &&
|
||||
c.height == _carton!.height) {
|
||||
selectedCatonSize = CartonSize(
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
@@ -122,7 +122,7 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
],
|
||||
);
|
||||
final createBtn = LocalButton(
|
||||
textKey: widget.isNew ? "box.new_carton_btn" : "box.cargo.save.btn",
|
||||
textKey: widget.isNew! ? "box.new_carton_btn" : "box.cargo.save.btn",
|
||||
callBack: _creatCarton,
|
||||
);
|
||||
|
||||
@@ -134,11 +134,10 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
List<CargoType> cargos = await Navigator.push<List<CargoType>>(
|
||||
List<CargoType>? cargos = await Navigator.push<List<CargoType>>(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
||||
if (cargos == null) return;
|
||||
if (cargos == null) return;
|
||||
setState(() {
|
||||
_cargoTypes.addAll(
|
||||
cargos.where((e) => !_cargoTypes.contains(e)).toList());
|
||||
@@ -168,7 +167,7 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
backgroundColor: Colors.white,
|
||||
title: LocalText(
|
||||
context,
|
||||
widget.isNew ? "boxes.create.title" : "box.edit.title",
|
||||
widget.isNew! ? "boxes.create.title" : "box.edit.title",
|
||||
fontSize: 20,
|
||||
color: primaryColor,
|
||||
),
|
||||
@@ -187,13 +186,14 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
deliveryAddress: _deliveryAddress,
|
||||
labelKey: "box.delivery_address",
|
||||
onTap: () async {
|
||||
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
|
||||
DeliveryAddress? d = await Navigator.push<DeliveryAddress>(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => DeliveryAddressSelection(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
user: User(
|
||||
id: _carton.userID, name: _carton.userName),
|
||||
id: _carton!.userID,
|
||||
name: _carton!.userName),
|
||||
)),
|
||||
);
|
||||
if (d == null) return;
|
||||
@@ -245,17 +245,17 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
height: 1,
|
||||
color: Colors.grey,
|
||||
),
|
||||
onChanged: (CartonSize newValue) {
|
||||
onChanged: (CartonSize? newValue) {
|
||||
setState(() {
|
||||
if (newValue.name == MANAGE_CARTONSIZE) {
|
||||
if (newValue!.name == MANAGE_CARTONSIZE) {
|
||||
selectedCatonSize = null;
|
||||
_manageCartonSize();
|
||||
return;
|
||||
}
|
||||
selectedCatonSize = newValue;
|
||||
_widthCtl.text = selectedCatonSize.width.toString();
|
||||
_heightCtl.text = selectedCatonSize.height.toString();
|
||||
_lengthCtl.text = selectedCatonSize.length.toString();
|
||||
_widthCtl.text = selectedCatonSize!.width.toString();
|
||||
_heightCtl.text = selectedCatonSize!.height.toString();
|
||||
_lengthCtl.text = selectedCatonSize!.length.toString();
|
||||
});
|
||||
},
|
||||
isExpanded: true,
|
||||
@@ -263,7 +263,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
|
||||
@@ -295,8 +295,7 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
|
||||
_updateCargo(CargoType cargo) {
|
||||
setState(() {
|
||||
var _c =
|
||||
_cargoTypes.firstWhere((e) => e.id == cargo.id, orElse: () => null);
|
||||
var _c = _cargoTypes.firstWhere((e) => e.id == cargo.id);
|
||||
if (_c != null) {
|
||||
_c.weight = cargo.weight;
|
||||
_c.qty = cargo.qty;
|
||||
@@ -305,13 +304,13 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
}
|
||||
|
||||
_creatCarton() async {
|
||||
if ((_cargoTypes?.length ?? 0) == 0) {
|
||||
if (_cargoTypes.length == 0) {
|
||||
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
||||
return;
|
||||
}
|
||||
double l = double.parse(_lengthCtl.text, (s) => 0);
|
||||
double w = double.parse(_widthCtl.text, (s) => 0);
|
||||
double h = double.parse(_heightCtl.text, (s) => 0);
|
||||
double l = double.parse(_lengthCtl.text);
|
||||
double w = double.parse(_widthCtl.text);
|
||||
double h = double.parse(_heightCtl.text);
|
||||
if ((l <= 0 || w <= 0 || h <= 0)) {
|
||||
showMsgDialog(context, "Error", "Invalid dimension");
|
||||
return;
|
||||
@@ -322,22 +321,22 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
}
|
||||
|
||||
Carton carton = Carton();
|
||||
carton.id = _carton.id;
|
||||
carton.cartonType = _carton.cartonType;
|
||||
carton.fcsShipmentID = _carton.fcsShipmentID;
|
||||
carton.id = _carton!.id;
|
||||
carton.cartonType = _carton!.cartonType;
|
||||
carton.fcsShipmentID = _carton!.fcsShipmentID;
|
||||
carton.cargoTypes = _cargoTypes;
|
||||
if (isFromPackages) {
|
||||
carton.userID = _carton.userID;
|
||||
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
|
||||
carton.userID = _carton!.userID;
|
||||
carton.packages = _carton!.packages.where((e) => e.isChecked).toList();
|
||||
}
|
||||
|
||||
if (isFromCartons) {
|
||||
carton.userID = _carton.userID;
|
||||
carton.fcsID = _carton.fcsID;
|
||||
carton.userName = _carton.userName;
|
||||
carton.senderID = _carton.senderID;
|
||||
carton.senderFCSID = _carton.senderFCSID;
|
||||
carton.senderName = _carton.senderName;
|
||||
carton.userID = _carton!.userID;
|
||||
carton.fcsID = _carton!.fcsID;
|
||||
carton.userName = _carton!.userName;
|
||||
carton.senderID = _carton!.senderID;
|
||||
carton.senderFCSID = _carton!.senderFCSID;
|
||||
carton.senderName = _carton!.senderName;
|
||||
}
|
||||
|
||||
carton.length = l;
|
||||
@@ -350,12 +349,12 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
try {
|
||||
CartonModel cartonModel =
|
||||
Provider.of<CartonModel>(context, listen: false);
|
||||
if (widget.isNew) {
|
||||
if (widget.isNew!) {
|
||||
Carton _c = await cartonModel.createCarton(carton);
|
||||
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) {
|
||||
|
||||
@@ -10,9 +10,9 @@ import 'package:fcs/pages/main/util.dart';
|
||||
typedef void ProfileCallback();
|
||||
|
||||
class TotalWeightEdit extends StatefulWidget {
|
||||
final double totalWeight;
|
||||
final double? totalWeight;
|
||||
|
||||
const TotalWeightEdit({Key key, this.totalWeight}) : super(key: key);
|
||||
const TotalWeightEdit({Key? key, this.totalWeight}) : super(key: key);
|
||||
@override
|
||||
_TotalWeightEditState createState() => _TotalWeightEditState();
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class _TotalWeightEditState extends State<TotalWeightEdit> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
totalController.text = widget.totalWeight.toStringAsFixed(2);
|
||||
totalController.text = widget.totalWeight!.toStringAsFixed(2);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -10,14 +10,14 @@ Widget getCartonNumberStatus(BuildContext context, Carton carton) {
|
||||
LocalText(
|
||||
context,
|
||||
'',
|
||||
text: carton.cartonNumber ?? "",
|
||||
text: carton.cartonNumber ,
|
||||
color: primaryColor,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Chip(label: Text(carton.status ?? "")),
|
||||
child: Chip(label: Text(carton.status)),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user