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

@@ -39,7 +39,7 @@ class DesktopOrderDetail extends StatefulWidget {
}
class DesktopOrderDetailState extends State<DesktopOrderDetail> {
late Order order;
Order? order;
late LatLng _lastMapPosition;
late LatLng customerLatLng;
@@ -110,7 +110,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
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(
@@ -129,7 +129,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
),
),
onTap: () {
Routes.router.navigateTo(context, '/shop/${order.businessId}/na/na/na');
Routes.router.navigateTo(context, '/shop/${order!.businessId}/na/na/na');
},
),
),
@@ -141,7 +141,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
Icons.phone,
),
onTap: () {
Utils.launchURL('tel:${order.businessInfo!.phone}');
Utils.launchURL('tel:${order!.businessInfo!.phone}');
},
),
),
@@ -150,13 +150,13 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
);
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: new LatLng(double.parse(order.shippingAddress!.lat!), double.parse(order.shippingAddress!.lng!)!),
target: new LatLng(double.parse(order!.shippingAddress!.lat!), double.parse(order!.shippingAddress!.lng!)!),
zoom: 11.0,
),
onCameraMove: _onCameraMove,
@@ -167,14 +167,14 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
].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(
@@ -190,7 +190,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
}
}
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),
@@ -289,7 +289,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
width: 100.0,
alignment: Alignment.centerRight,
child: Text(
'${order.getSubtotal().toStringAsFixed(2)}',
'${order!.getSubtotal().toStringAsFixed(2)}',
style: TextStyle(
fontSize: 15.0,
),
@@ -298,8 +298,8 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
],
),
);
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,
@@ -356,7 +356,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
width: 100.0,
alignment: Alignment.centerRight,
child: Text(
'${order.totalPrice!.toStringAsFixed(2)}',
'${order!.totalPrice!.toStringAsFixed(2)}',
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
@@ -409,7 +409,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
),
),
);
if (order.shippingMethod != 'pickup') {
if (order!.shippingMethod != 'pickup') {
col.children.add(Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
@@ -428,7 +428,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
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,
),
@@ -466,7 +466,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
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,
),
@@ -505,7 +505,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
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,
),
@@ -543,7 +543,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
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,
),
@@ -633,7 +633,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
'${order.orderNum}',
'${order!.orderNum}',
style: TextStyle(
color: Colors.black38,
),
@@ -655,7 +655,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
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,
@@ -700,7 +700,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
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,
),
@@ -741,15 +741,15 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
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,
@@ -759,16 +759,16 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
) : 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}');
},
),
],
@@ -806,7 +806,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
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,
),
@@ -862,7 +862,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
),
),
Text(
Utils.getOrderStatus(context, order.status!),
Utils.getOrderStatus(context, order!.status!),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -884,7 +884,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
),
),);
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,
@@ -963,13 +963,13 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
back: true,
breadCrumbs: [
BreadCrumb(S.of(context).order_detail, null),
BreadCrumb('#${order.orderNum}', null)
BreadCrumb('#${order!.orderNum}', null)
],
breadCrumbHeight: Constants.BREADCRUMB_HEIGHT,
),
body: WillPopScope(
onWillPop: () async {
if (widget.fromOrders != null && widget.fromOrders) {
if (widget.fromOrders == true) {
return true;
} else {
Routes.router.navigateTo(
@@ -1000,7 +1000,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
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,
@@ -1015,7 +1015,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
) : 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,
style: TextStyle(
@@ -1023,16 +1023,16 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
),
),
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,
@@ -1042,7 +1042,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
),
),
onPressed: () {
Routes.router.navigateTo(context, '/paynow/${order.id}');
Routes.router.navigateTo(context, '/paynow/${order!.id}');
},
) : TextButton(
child: Text(
@@ -1053,7 +1053,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
),
),
onPressed: () {
Utils.orderAgain(context, order.cartInfo!);
Utils.orderAgain(context, order!.cartInfo!);
},
),
),
@@ -1091,13 +1091,13 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
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(
@@ -1110,7 +1110,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
],
width: 3,
points: [
order.shipperPosition!.lat != 0.0 ? deliveryLatLng : storeLatLng,
order!.shipperPosition!.lat != 0.0 ? deliveryLatLng : storeLatLng,
customerLatLng,
]
)
@@ -1135,12 +1135,12 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
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,