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

@@ -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();