phase3: nullable fields/methods, casts, ?.call, condition fixes across 11 files. 108->72

This commit is contained in:
2026-08-01 01:16:25 +08:00
parent b8b70a87f9
commit 137eca4c69
12 changed files with 164 additions and 164 deletions

View File

@@ -119,13 +119,13 @@ class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
});
ProductAttribute pa = product.productAttributes![index];
if (pa.required && Utils.selectionsNotEmptyAt(selections, pa.name!)) {
if (pa.required == true && Utils.selectionsNotEmptyAt(selections, pa.name!)) {
setState(() {
nextButtonEnable = true;
productDesc = product.description! + ', ' + extendDescription.join('; ');
productPrice = product.price! + extendPrice;
});
} else if (!pa.required){
} else if (pa.required != true){
setState(() {
nextButtonEnable = true;
productDesc = product.description! + ', ' + extendDescription.join('; ');
@@ -143,9 +143,9 @@ class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
bool _checkCanGoNext() {
ProductAttribute pa = product.productAttributes![index];
if (pa.required && Utils.selectionsNotEmptyAt(selections, pa.name!)) {
if (pa.required == true && Utils.selectionsNotEmptyAt(selections, pa.name!)) {
return true;
} else if (!pa.required){
} else if (pa.required != true){
return true;
}
return false;

View File

@@ -110,7 +110,7 @@ class MobileEditAddressState extends State<MobileEditAddress> {
.contact_name,
),
validator: (String? value) {
if (value
if (value!
.trim()
.isEmpty) {
return S
@@ -165,7 +165,7 @@ class MobileEditAddressState extends State<MobileEditAddress> {
.mobile_phone_number,
),
validator: (String? value) {
if (value
if (value!
.trim()
.isEmpty) {
return S
@@ -197,7 +197,7 @@ class MobileEditAddressState extends State<MobileEditAddress> {
.street_line_1,
),
validator: (String? value) {
if (value
if (value!
.trim()
.isEmpty) {
return S
@@ -251,7 +251,7 @@ class MobileEditAddressState extends State<MobileEditAddress> {
.city,
),
validator: (String? value) {
if (value
if (value!
.trim()
.isEmpty) {
return S
@@ -321,7 +321,7 @@ class MobileEditAddressState extends State<MobileEditAddress> {
.postal_code,
),
validator: (String? value) {
if (value
if (value!
.trim()
.isEmpty) {
return S

View File

@@ -37,7 +37,7 @@ class MobileOrderDetail extends StatefulWidget {
}
class MobileOrderDetailState extends State<MobileOrderDetail> {
late Order order;
Order? order;
late LatLng _lastMapPosition;
late LatLng customerLatLng;
@@ -80,7 +80,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
leading: IconButton(
icon: Icon(Icons.arrow_back_ios),
onPressed: (){
if (widget.fromOrders != null && widget.fromOrders) {
if (widget.fromOrders == true) {
Navigator.of(context).pop();
} else {
Routes.router.navigateTo(
@@ -93,7 +93,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
),
body: WillPopScope(
onWillPop: () async {
if (widget.fromOrders != null && widget.fromOrders) {
if (widget.fromOrders == true) {
return true;
} else {
Routes.router.navigateTo(
@@ -123,7 +123,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
width: double.infinity,
padding: EdgeInsets.only(top: 0.0, bottom: 16.0),
child: Text(
order.cartInfo!.businessInfo!.name!,
order!.cartInfo!.businessInfo!.name!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -142,7 +142,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
),
),
onTap: () {
Routes.router.navigateTo(context, '/shop/${order.businessId}/na/na/na');
Routes.router.navigateTo(context, '/shop/${order!.businessId}/na/na/na');
},
),
),
@@ -154,7 +154,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
Icons.phone,
),
onTap: () {
Utils.launchURL('tel:${order.businessInfo!.phone}');
Utils.launchURL('tel:${order!.businessInfo!.phone}');
},
),
),
@@ -163,15 +163,15 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
);
if (!kIsWeb) {
if (order.shippingMethod == 'store-delivery' && order.status != Constants.STATUS_COMPLETE && order.status != Constants.STATUS_CANCELLED) {
if (order!.shippingMethod == 'store-delivery' && order!.status != Constants.STATUS_COMPLETE && order!.status != Constants.STATUS_CANCELLED) {
col.children.add(Container(
height: 200.0,
child: GoogleMap(
onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition(
target: LatLng(
double.parse(order.shippingAddress!.lat!),
double.parse(order.shippingAddress!.lng!)),
double.parse(order!.shippingAddress!.lat!),
double.parse(order!.shippingAddress!.lng!)),
zoom: 11.0,
),
onCameraMove: _onCameraMove,
@@ -182,14 +182,14 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
].toSet(),
),
));
if (order.deliveryDistance != null && order.deliveryDistance!.distance != null) {
if (order!.deliveryDistance != null && order!.deliveryDistance!.distance != null) {
col.children.add(Container(
padding: EdgeInsets.only(top: 6.0, bottom: 6.0),
margin: EdgeInsets.only(bottom: 6.0),
child: Text(
S.of(context).delivery_distance_token(
order.deliveryDistance!.distance!.text!,
order.deliveryDistance!.duration!.text!
order!.deliveryDistance!.distance!.text!,
order!.deliveryDistance!.duration!.text!
),
),
decoration: BoxDecoration(
@@ -205,7 +205,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
}
}
for (CartLineItem lineItem in order.cartInfo!.productList!) {
for (CartLineItem lineItem in order!.cartInfo!.productList!) {
col.children.add(Container(
padding: EdgeInsets.only(top: 16.0, bottom: 0.0),
@@ -304,7 +304,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
width: 100.0,
alignment: Alignment.centerRight,
child: Text(
'${order.getSubtotal().toStringAsFixed(2)}',
'${order!.getSubtotal().toStringAsFixed(2)}',
style: TextStyle(
fontSize: 15.0,
),
@@ -313,8 +313,8 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
],
),
);
for (var i = 0; i < order.cartInfo!.extraFeeList!.length; i++) {
ExtraFee extraFee = order.cartInfo!.extraFeeList![i];
for (var i = 0; i < order!.cartInfo!.extraFeeList!.length; i++) {
ExtraFee extraFee = order!.cartInfo!.extraFeeList![i];
col.children.add(
Row(
mainAxisAlignment: MainAxisAlignment.start,
@@ -371,7 +371,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
width: 100.0,
alignment: Alignment.centerRight,
child: Text(
'${order.totalPrice!.toStringAsFixed(2)}',
'${order!.totalPrice!.toStringAsFixed(2)}',
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
@@ -424,7 +424,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
),
),
);
if (order.shippingMethod != 'pickup') {
if (order!.shippingMethod != 'pickup') {
col.children.add(Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
@@ -443,7 +443,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
child: Container(
margin: EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Text(
'${order.address}, ${order.consignee}, ${order.phone}',
'${order!.address}, ${order!.consignee}, ${order!.phone}',
style: TextStyle(
color: Colors.black38,
),
@@ -481,7 +481,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
margin: EdgeInsets.only(top: 10.0, bottom: 10.0),
alignment: Alignment.centerRight,
child: Text(
'${order.cartInfo!.businessInfo!.fullAddress}',
'${order!.cartInfo!.businessInfo!.fullAddress}',
style: TextStyle(
color: Colors.black38,
),
@@ -520,7 +520,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
margin: EdgeInsets.only(top: 10.0, bottom: 10.0),
alignment: Alignment.centerRight,
child: Text(
'${Utils.timestampToString(context, order.bookedAt!, withTime: true)}',
'${Utils.timestampToString(context, order!.bookedAt!, withTime: true)}',
style: TextStyle(
color: Colors.black38,
),
@@ -558,7 +558,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
margin: EdgeInsets.only(top: 10.0, bottom: 10.0),
alignment: Alignment.centerRight,
child: Text(
order.shippingMethod == 'pickup' ? S.of(context).pickup : S.of(context).store_delivery,
order!.shippingMethod == 'pickup' ? S.of(context).pickup : S.of(context).store_delivery,
style: TextStyle(
color: Colors.black38,
),
@@ -648,7 +648,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
'${order.orderNum}',
'${order!.orderNum}',
style: TextStyle(
color: Colors.black38,
),
@@ -670,7 +670,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
S.of(context).copy,
),
onTap: () {
Clipboard.setData(ClipboardData(text: '${order.orderNum}'));
Clipboard.setData(ClipboardData(text: '${order!.orderNum}'));
Fluttertoast.showToast(
msg: S.of(context).order_number_copied_to_clipboard,
toastLength: Toast.LENGTH_SHORT,
@@ -715,7 +715,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
margin: EdgeInsets.only(top: 10.0, bottom: 10.0),
alignment: Alignment.centerRight,
child: Text(
order.payMethod == 0 ? S.of(context).online_payment : S.of(context).pay_on_deliery,
order!.payMethod == 0 ? S.of(context).online_payment : S.of(context).pay_on_deliery,
style: TextStyle(
color: Colors.black38,
),
@@ -756,15 +756,15 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
order.paymentStatus == Constants.PAYMENT_STATUS_PAID ? S.of(context).paid : S.of(context).unpaid,
order!.paymentStatus == Constants.PAYMENT_STATUS_PAID ? S.of(context).paid : S.of(context).unpaid,
style: TextStyle(
color: Colors.black38,
),
),
Container(
margin: order.paymentStatus != Constants.PAYMENT_STATUS_PAID && order.status != Constants.STATUS_CANCELLED ? EdgeInsets.only(left: 10.0, right: 10.0) : EdgeInsets.only(left: 0.0, right: 0.0),
child: order.paymentStatus != Constants.PAYMENT_STATUS_PAID && order.status != Constants.STATUS_CANCELLED ? Text('') : SizedBox.shrink(),
decoration: order.paymentStatus != Constants.PAYMENT_STATUS_PAID && order.status != Constants.STATUS_CANCELLED ? BoxDecoration(
margin: order!.paymentStatus != Constants.PAYMENT_STATUS_PAID && order!.status != Constants.STATUS_CANCELLED ? EdgeInsets.only(left: 10.0, right: 10.0) : EdgeInsets.only(left: 0.0, right: 0.0),
child: order!.paymentStatus != Constants.PAYMENT_STATUS_PAID && order!.status != Constants.STATUS_CANCELLED ? Text('') : SizedBox.shrink(),
decoration: order!.paymentStatus != Constants.PAYMENT_STATUS_PAID && order!.status != Constants.STATUS_CANCELLED ? BoxDecoration(
border: Border(
left: BorderSide(
width: 0.5,
@@ -774,16 +774,16 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
) : null,
),
GestureDetector(
child: order.paymentStatus != Constants.PAYMENT_STATUS_PAID
&& order.status != Constants.STATUS_CANCELLED
&& order.status != Constants.STATUS_COMPLETE ? Text(
child: order!.paymentStatus != Constants.PAYMENT_STATUS_PAID
&& order!.status != Constants.STATUS_CANCELLED
&& order!.status != Constants.STATUS_COMPLETE ? Text(
S.of(context).pay_now,
style: TextStyle(
fontWeight: FontWeight.bold,
),
) : SizedBox.shrink(),
onTap: () {
Routes.router.navigateTo(context, '/paynow/${order.id}');
Routes.router.navigateTo(context, '/paynow/${order!.id}');
},
),
],
@@ -821,7 +821,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
margin: EdgeInsets.only(top: 10.0, bottom: 10.0),
alignment: Alignment.centerRight,
child: Text(
Utils.timestampToString(context, order.createdAt!, withTime: true),
Utils.timestampToString(context, order!.createdAt!, withTime: true),
style: TextStyle(
color: Colors.black38,
),
@@ -877,7 +877,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
),
),
Text(
Utils.getOrderStatus(context, order.status!),
Utils.getOrderStatus(context, order!.status!),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -899,7 +899,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
),
),);
for (Fulfillment fulfillment in order.fulfillments!) {
for (Fulfillment fulfillment in order!.fulfillments!) {
col.children.add(Container(
padding: EdgeInsets.only(top: 10.0, bottom: 10.0),
width: double.infinity,
@@ -983,7 +983,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
children: <Widget>[
Container(
padding: EdgeInsets.only(right: 10.0),
child: order.status == Constants.STATUS_PENDING && order.paymentStatus == Constants.PAYMENT_STATUS_UNPAID ?
child: order!.status == Constants.STATUS_PENDING && order!.paymentStatus == Constants.PAYMENT_STATUS_UNPAID ?
TextButton(
child: Text(
S.of(context).cancel_order,
@@ -994,34 +994,34 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
) : SizedBox.shrink(),
),
Container(
child: order.status == Constants.STATUS_COMPLETE && !order.hasComment ? ElevatedButton(
child: order!.status == Constants.STATUS_COMPLETE && order!.hasComment != true ? ElevatedButton(
child: Text(
S.of(context).comment,
),
onPressed: () {
Routes.router.navigateTo(context, '/new-comment/${order.id}');
Routes.router.navigateTo(context, '/new-comment/${order!.id}');
},
) : SizedBox.shrink(),
),
],
),
Container(
child: order.paymentStatus != Constants.PAYMENT_STATUS_PAID
&& order.status != Constants.STATUS_CANCELLED
&& order.status != Constants.STATUS_COMPLETE ?
child: order!.paymentStatus != Constants.PAYMENT_STATUS_PAID
&& order!.status != Constants.STATUS_CANCELLED
&& order!.status != Constants.STATUS_COMPLETE ?
TextButton(
child: Text(
S.of(context).pay_now,
),
onPressed: () {
Routes.router.navigateTo(context, '/paynow/${order.id}');
Routes.router.navigateTo(context, '/paynow/${order!.id}');
},
) : TextButton(
child: Text(
S.of(context).order_again,
),
onPressed: () {
Utils.orderAgain(context, order.cartInfo!);
Utils.orderAgain(context, order!.cartInfo!);
},
),
),
@@ -1059,13 +1059,13 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
order = Order.fromJson(data);
if (!kIsWeb) {
if (order.shippingMethod == 'store-delivery' && order.status != Constants.STATUS_COMPLETE && order.status != Constants.STATUS_CANCELLED) {
storeLatLng = LatLng(double.parse(order.businessInfo!.address!.lat!),
double.parse(order.businessInfo!.address!.lng!));
customerLatLng = LatLng(double.parse(order.shippingAddress!.lat!),
double.parse(order.shippingAddress!.lng!));
if (order!.shippingMethod == 'store-delivery' && order!.status != Constants.STATUS_COMPLETE && order!.status != Constants.STATUS_CANCELLED) {
storeLatLng = LatLng(double.parse(order!.businessInfo!.address!.lat!),
double.parse(order!.businessInfo!.address!.lng!));
customerLatLng = LatLng(double.parse(order!.shippingAddress!.lat!),
double.parse(order!.shippingAddress!.lng!));
deliveryLatLng =
LatLng(order.shipperPosition!.lat!, order.shipperPosition!.lng!);
LatLng(order!.shipperPosition!.lat!, order!.shipperPosition!.lng!);
_polyLine.clear();
_polyLine.add(
@@ -1078,7 +1078,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
],
width: 3,
points: [
order.shipperPosition!.lat != 0.0 ? deliveryLatLng : storeLatLng,
order!.shipperPosition!.lat != 0.0 ? deliveryLatLng : storeLatLng,
customerLatLng,
]
)
@@ -1103,12 +1103,12 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
title: S
.of(context)
.customer,
snippet: order.shippingAddress!.addressLine1,
snippet: order!.shippingAddress!.addressLine1,
),
icon: homeIcon,
));
if (order.shipperPosition!.lat != 0.0 &&
order.shipperPosition!.lng != 0.0) {
if (order!.shipperPosition!.lat != 0.0 &&
order!.shipperPosition!.lng != 0.0) {
_markers.add(Marker(
markerId: MarkerId('shipper_position'),
position: deliveryLatLng,