phase3(wip): desktop_checkout field null-safety + build local-shadow

This commit is contained in:
2026-07-25 02:53:03 +08:00
parent e2f0d37edd
commit 8f3d3509ea

View File

@@ -47,17 +47,17 @@ class DesktopCheckout extends StatefulWidget {
}
class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
CartInfo cartInfo;
Address shipAddress;
bool canSubmit;
List<ErrorMessage> errorMessages;
List<BookingTime> bookingTimeList;
List<BookingDateTime> bookingDateTimeList;
List<PaymentPlatform> paymentPlatforms;
TextValue durationInTraffic;
int selectedCoupon;
CartInfo? cartInfo;
Address? shipAddress;
bool canSubmit = false;
List<ErrorMessage> errorMessages = [];
List<BookingTime> bookingTimeList = [];
List<BookingDateTime> bookingDateTimeList = [];
List<PaymentPlatform> paymentPlatforms = [];
TextValue? durationInTraffic;
int? selectedCoupon;
double couponDiscountAmount = 0;
List<Coupon> coupons;
List<Coupon>? coupons;
int peopleCount = 2;
@@ -65,25 +65,25 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
String orderRemark = '';
int deliveryMethodIndex = 0;
String deliveryMethod;
String? deliveryMethod;
List<ShippingRate> shippingRates = [];
ShippingRate selectedShippingRate;
ShippingRate? selectedShippingRate;
List<String> shippingMethodLabels = [];
List<IconData> shippingMethodIcons = [];
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
int bookingDateIndex;
int bookingTimeIndex;
int paymentPlatformIndex;
int bookingDateIndex = 0;
int bookingTimeIndex = 0;
int paymentPlatformIndex = 0;
GlobalKey slidingUpPanelKey = GlobalKey();
SlidingUpPanel slidingUpPanel;
SlidingUpPanel? slidingUpPanel;
PanelController panelController = PanelController();
Widget panel;
Widget? panel;
double subtotal;
double subtotal = 0;
TextEditingController newCouponController = TextEditingController();
@@ -104,7 +104,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
store.dispatch(UpdateContext(context));
if (cartInfo == null ) {
if (this.cartInfo == null ) {
return new Scaffold(
body: Center(
child: SpinKitWave(
@@ -114,8 +114,13 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
),
);
}
final cartInfo = this.cartInfo!;
final businessInfo = cartInfo.businessInfo;
if (cartInfo.businessInfo.deliveryPickup == false && cartInfo.businessInfo.deliveryCanadaPost == false && cartInfo.businessInfo.deliveryStoreDelivery == false) {
if (businessInfo == null ||
businessInfo.deliveryPickup != true &&
businessInfo.deliveryCanadaPost != true &&
businessInfo.deliveryStoreDelivery != true) {
return Scaffold(
body: Container(
child: Center(
@@ -163,7 +168,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
backdropTapClosesPanel: false,
isDraggable: false,
controller: panelController,
panel: panel,
panel: panel ?? SizedBox.shrink(),
body: Row(
children: [
Container(
@@ -189,7 +194,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
breadCrumbHeight: Constants.BREADCRUMB_HEIGHT,
),
body: WillPopScope(
child: slidingUpPanel,
child: slidingUpPanel ?? SizedBox.shrink(),
onWillPop: () async {
if (panelController != null && panelController.isPanelOpen) {
panelController.close();
@@ -223,7 +228,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
color: Colors.white,
),
),
cartInfo.businessInfo.isPublic ? SizedBox.shrink() : Container(
(cartInfo.businessInfo?.isPublic ?? false) ? SizedBox.shrink() : Container(
padding: EdgeInsets.only(top: 2.0, bottom: 2.0, left: 5.0, right: 5.0),
width: 100.0,
color: Colors.red,