phase3: checkout files clean (nullable fields, ternary/concat/condition fixes). 142->131

This commit is contained in:
2026-07-31 15:05:08 +08:00
parent a6d5b9cd2d
commit 5cb5ef6396
3 changed files with 30 additions and 30 deletions

View File

@@ -46,13 +46,13 @@ class MobileCheckout extends StatefulWidget {
class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
late CartInfo cartInfo;
late Address shipAddress;
Address? shipAddress;
late bool canSubmit;
late List<ErrorMessage> errorMessages;
late List<BookingTime> bookingTimeList;
late List<BookingDateTime> bookingDateTimeList;
late List<PaymentPlatform> paymentPlatforms;
late TextValue durationInTraffic;
TextValue? durationInTraffic;
late int selectedCoupon;
double couponDiscountAmount = 0;
late List<Coupon> coupons;
@@ -65,7 +65,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
int deliveryMethodIndex = 0;
late String deliveryMethod;
List<ShippingRate> shippingRates = [];
late ShippingRate selectedShippingRate;
ShippingRate? selectedShippingRate;
List<String> shippingMethodLabels = [];
List<IconData> shippingMethodIcons = [];
@@ -203,7 +203,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
color: Colors.white,
),
),
cartInfo.businessInfo!.isPublic ? SizedBox.shrink() : Container(
cartInfo.businessInfo!.isPublic == true ? SizedBox.shrink() : Container(
padding: EdgeInsets.only(top: 2.0, bottom: 2.0, left: 5.0, right: 5.0),
width: 100.0,
color: Colors.red,
@@ -267,7 +267,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
itemCount: 6,
addAutomaticKeepAlives: true,
itemBuilder: (BuildContext context, int position) {
var deliveryTimeInSeconds = cartInfo.businessInfo!.shippingTime! * 60 + (durationInTraffic != null ? durationInTraffic.value : 0);
var deliveryTimeInSeconds = cartInfo.businessInfo!.shippingTime! * 60 + (durationInTraffic != null ? durationInTraffic!.value ?? 0 : 0);
print('aaa: $deliveryTimeInSeconds');
DateTime now = DateTime.now();
var formatter = DateFormat('H:mm');
@@ -469,7 +469,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
children: <Widget>[
Container(
child: Text(
shipAddress != null ? shipAddress.fullAddress : S.of(context).enter_delivery_address,
shipAddress != null ? shipAddress!.fullAddress! : S.of(context).enter_delivery_address,
style: TextStyle(
fontSize: 16.0
),
@@ -480,7 +480,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
Container(
padding: EdgeInsets.only(top: 6.0),
child: Text(
shipAddress != null ? shipAddress.contactName! + ' ' + shipAddress.phone : '',
shipAddress != null ? shipAddress!.contactName! + ' ' + shipAddress!.phone! : '',
style: TextStyle(
fontSize: 14.0,
color: Colors.black38,
@@ -553,7 +553,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
alignment: Alignment.centerRight,
child: Text(
selectedShippingRate != null ?
'${selectedShippingRate.name} \$${selectedShippingRate.price!.toStringAsFixed(2)}' :
'${selectedShippingRate!.name} \$${selectedShippingRate!.price!.toStringAsFixed(2)}' :
S.of(context).please_select,
style: TextStyle(
fontSize: 15.0,
@@ -629,7 +629,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
child: Text(
bookingTimeList.length > 0 ? '${Utils.timestampToString(context, bookingTimeList[bookingTimeIndex].unixTime!)}'
: ((bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ? ''
: bookingDateTimeList[bookingDateIndex].viewDate! + ' ' + (bookingDateTimeList[bookingDateIndex].bookTimes!.length > 0 ? bookingDateTimeList[bookingDateIndex].bookTimes![bookingTimeIndex].viewTime : '')),
: bookingDateTimeList[bookingDateIndex].viewDate! + ' ' + (bookingDateTimeList[bookingDateIndex].bookTimes!.length > 0 ? bookingDateTimeList[bookingDateIndex].bookTimes![bookingTimeIndex].viewTime! : '')),
),
),
Container(
@@ -1050,7 +1050,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
if (cartInfo != null) {
Utils.showLoadingDialog(context);
}
CartInfo ci = Utils.getCartInfoByBusinessId(store.state.cartInfos, widget.businessId);
CartInfo ci = Utils.getCartInfoByBusinessId(store.state.cartInfos, widget.businessId)!;
HttpUtil.httpPost('v1/orders/check', (response) {
if (cartInfo != null) {
Navigator.of(context).pop();
@@ -1681,7 +1681,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
return GestureDetector(
child: Container(
decoration: selectedCoupon == 0 ? BoxDecoration(
color: subtotal > cartInfo.businessInfo!.minPrice ? Colors
color: subtotal > cartInfo.businessInfo!.minPrice! ? Colors
.transparent : Colors.black38,
border: Border(
top: BorderSide(
@@ -1702,7 +1702,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
),
),
) : BoxDecoration(
color: subtotal > cartInfo.businessInfo!.minPrice ? Colors
color: subtotal > cartInfo.businessInfo!.minPrice! ? Colors
.transparent : Colors.black38,
),
child: Row(
@@ -1743,7 +1743,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
return GestureDetector(
child: Container(
decoration: selectedCoupon == coupon.id ? BoxDecoration(
color: subtotal > cartInfo.businessInfo!.minPrice ? Colors
color: subtotal > cartInfo.businessInfo!.minPrice! ? Colors
.transparent : Colors.black38,
border: Border(
top: BorderSide(
@@ -1764,7 +1764,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
),
),
) : BoxDecoration(
color: subtotal > coupon.minAmount ? Colors
color: subtotal > coupon.minAmount! ? Colors
.transparent : Colors.black26,
),
child: Row(
@@ -1774,7 +1774,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
Container(
padding: EdgeInsets.only(
left: 16.0, top: 16.0, right: 16.0, bottom: 16.0),
child: coupon.isPercentage ?
child: coupon.isPercentage == true ?
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
@@ -1885,12 +1885,12 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
),
),
onTap: () {
if (subtotal > coupon.minAmount &&
if (subtotal > coupon.minAmount! &&
mounted) {
setState(() {
selectedCoupon = coupon.id!;
if (coupon.isPercentage == true) {
couponDiscountAmount = subtotal * coupon.valueAmount / 100.0;
couponDiscountAmount = subtotal * coupon.valueAmount! / 100.0;
} else {
couponDiscountAmount = coupon.valueAmount!;
}