phase3: precise nullable-condition fixes (if(x)->if(x==true), analyzer-driven). 399->379

This commit is contained in:
2026-07-26 10:46:26 +08:00
parent 97e4908126
commit 3ed58e1596
6 changed files with 20 additions and 20 deletions

View File

@@ -366,7 +366,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
); );
switch (position) { switch (position) {
case 0: case 0:
if (cartInfo!.businessInfo!.deliveryPickup) { if (cartInfo!.businessInfo!.deliveryPickup == true) {
return Container( return Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 16.0, bottom: 16.0, left: 16.0, right: 16.0), top: 16.0, bottom: 16.0, left: 16.0, right: 16.0),
@@ -608,7 +608,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
}, },
); );
} }
if (!cartInfo!.businessInfo!.instanceDelivery) { if (cartInfo!.businessInfo!.instanceDelivery != true) {
return Container( return Container(
padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 0.0, bottom: 16.0), padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 0.0, bottom: 16.0),
child: Text(S.of(context).no_instance_delivery_desc), child: Text(S.of(context).no_instance_delivery_desc),
@@ -1099,7 +1099,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
shippingRates = (response.data['shipping_rates'] as List).map((e) => ShippingRate.fromJson(e)).toList(); shippingRates = (response.data['shipping_rates'] as List).map((e) => ShippingRate.fromJson(e)).toList();
selectedShippingRate = (response.data['selected_shipping_rate'] as String).length > 0 ? ShippingRate.fromJson(json.decode(response.data['selected_shipping_rate'])) : null; selectedShippingRate = (response.data['selected_shipping_rate'] as String).length > 0 ? ShippingRate.fromJson(json.decode(response.data['selected_shipping_rate'])) : null;
int i = 0; int i = 0;
if (cartInfo!.businessInfo!.deliveryStoreDelivery) { if (cartInfo!.businessInfo!.deliveryStoreDelivery == true) {
shippingMethodLabels.add(S.of(context).delivery); shippingMethodLabels.add(S.of(context).delivery);
shippingMethodIcons.add(Icons.directions_car); shippingMethodIcons.add(Icons.directions_car);
if (deliveryMethod == 'store-delivery') { if (deliveryMethod == 'store-delivery') {
@@ -1107,7 +1107,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
} }
i++; i++;
} }
if (cartInfo!.businessInfo!.deliveryCanadaPost) { if (cartInfo!.businessInfo!.deliveryCanadaPost == true) {
shippingMethodLabels.add(S.of(context).canada_post); shippingMethodLabels.add(S.of(context).canada_post);
shippingMethodIcons.add(Icons.local_shipping); shippingMethodIcons.add(Icons.local_shipping);
if (deliveryMethod == 'canada-post') { if (deliveryMethod == 'canada-post') {
@@ -1115,7 +1115,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
} }
i++; i++;
} }
if (cartInfo!.businessInfo!.deliveryPickup) { if (cartInfo!.businessInfo!.deliveryPickup == true) {
shippingMethodLabels.add(S.of(context).pickup); shippingMethodLabels.add(S.of(context).pickup);
shippingMethodIcons.add(Icons.store); shippingMethodIcons.add(Icons.store);
if (deliveryMethod == 'pickup') { if (deliveryMethod == 'pickup') {
@@ -1580,7 +1580,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
} else { } else {
for (var i = 0; i < coupons!.length; i++) { for (var i = 0; i < coupons!.length; i++) {
if (selectedCoupon == coupons![i].id) { if (selectedCoupon == coupons![i].id) {
if (coupons![i].isPercentage) { if (coupons![i].isPercentage == true) {
return S.of(context).percentage_discount_token2(couponDiscountAmount.toStringAsFixed(2), coupons![i].valueAmount); return S.of(context).percentage_discount_token2(couponDiscountAmount.toStringAsFixed(2), coupons![i].valueAmount);
} else { } else {
return S.of(context).discount_amount_token(couponDiscountAmount.toStringAsFixed(2)); return S.of(context).discount_amount_token(couponDiscountAmount.toStringAsFixed(2));
@@ -1914,7 +1914,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
mounted) { mounted) {
setState(() { setState(() {
selectedCoupon = coupon.id; selectedCoupon = coupon.id;
if (coupon.isPercentage) { if (coupon.isPercentage == true) {
couponDiscountAmount = subtotal * coupon.valueAmount / 100.0; couponDiscountAmount = subtotal * coupon.valueAmount / 100.0;
} else { } else {
couponDiscountAmount = coupon.valueAmount!; couponDiscountAmount = coupon.valueAmount!;

View File

@@ -85,7 +85,7 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
'adjust_amount': adjustAmount 'adjust_amount': adjustAmount
}; };
var cloneSelections = json.decode(json.encode(selections)); var cloneSelections = json.decode(json.encode(selections));
if (product.productAttributes![index].required) { if (product.productAttributes![index].required == true) {
cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt]; cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt];
} else { } else {
if (cloneSelections.containsKey(product.productAttributes![index].name!.toUpperCase()) if (cloneSelections.containsKey(product.productAttributes![index].name!.toUpperCase())

View File

@@ -240,10 +240,10 @@ class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
Widget optionsView; Widget optionsView;
ProductAttribute productAttribute = product.productAttributes![index]; ProductAttribute productAttribute = product.productAttributes![index];
if (productAttribute.byQuantity) { if (productAttribute.byQuantity == true) {
optionsView = new QtyOptions(product: product, index: index, selections: selections); optionsView = new QtyOptions(product: product, index: index, selections: selections);
} else { } else {
if (productAttribute.singleSelection) { if (productAttribute.singleSelection == true) {
optionsView = new RadioOptions(product: product, index: index, selections: selections); optionsView = new RadioOptions(product: product, index: index, selections: selections);
} else { } else {
optionsView = new CheckOptions(product: product, index: index, selections: selections); optionsView = new CheckOptions(product: product, index: index, selections: selections);

View File

@@ -341,7 +341,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
); );
switch (position) { switch (position) {
case 0: case 0:
if (cartInfo.businessInfo!.deliveryPickup) { if (cartInfo.businessInfo!.deliveryPickup == true) {
return Container( return Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 16.0, bottom: 16.0, left: 16.0, right: 16.0), top: 16.0, bottom: 16.0, left: 16.0, right: 16.0),
@@ -583,7 +583,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
}, },
); );
} }
if (!cartInfo.businessInfo!.instanceDelivery) { if (cartInfo.businessInfo!.instanceDelivery != true) {
return Container( return Container(
padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 0.0, bottom: 16.0), padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 0.0, bottom: 16.0),
child: Text(S.of(context).no_instance_delivery_desc), child: Text(S.of(context).no_instance_delivery_desc),
@@ -1074,7 +1074,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
shippingRates = (response.data['shipping_rates'] as List).map((e) => ShippingRate.fromJson(e)).toList(); shippingRates = (response.data['shipping_rates'] as List).map((e) => ShippingRate.fromJson(e)).toList();
selectedShippingRate = (response.data['selected_shipping_rate'] as String).length > 0 ? ShippingRate.fromJson(json.decode(response.data['selected_shipping_rate'])) : null; selectedShippingRate = (response.data['selected_shipping_rate'] as String).length > 0 ? ShippingRate.fromJson(json.decode(response.data['selected_shipping_rate'])) : null;
int i = 0; int i = 0;
if (cartInfo.businessInfo!.deliveryStoreDelivery) { if (cartInfo.businessInfo!.deliveryStoreDelivery == true) {
shippingMethodLabels.add(S.of(context).delivery); shippingMethodLabels.add(S.of(context).delivery);
shippingMethodIcons.add(Icons.directions_car); shippingMethodIcons.add(Icons.directions_car);
if (deliveryMethod == 'store-delivery') { if (deliveryMethod == 'store-delivery') {
@@ -1082,7 +1082,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
} }
i++; i++;
} }
if (cartInfo.businessInfo!.deliveryCanadaPost) { if (cartInfo.businessInfo!.deliveryCanadaPost == true) {
shippingMethodLabels.add(S.of(context).canada_post); shippingMethodLabels.add(S.of(context).canada_post);
shippingMethodIcons.add(Icons.local_shipping); shippingMethodIcons.add(Icons.local_shipping);
if (deliveryMethod == 'canada-post') { if (deliveryMethod == 'canada-post') {
@@ -1090,7 +1090,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
} }
i++; i++;
} }
if (cartInfo.businessInfo!.deliveryPickup) { if (cartInfo.businessInfo!.deliveryPickup == true) {
shippingMethodLabels.add(S.of(context).pickup); shippingMethodLabels.add(S.of(context).pickup);
shippingMethodIcons.add(Icons.store); shippingMethodIcons.add(Icons.store);
if (deliveryMethod == 'pickup') { if (deliveryMethod == 'pickup') {
@@ -1555,7 +1555,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
} else { } else {
for (var i = 0; i < coupons.length; i++) { for (var i = 0; i < coupons.length; i++) {
if (selectedCoupon == coupons[i].id) { if (selectedCoupon == coupons[i].id) {
if (coupons[i].isPercentage) { if (coupons[i].isPercentage == true) {
return S.of(context).percentage_discount_token2(couponDiscountAmount.toStringAsFixed(2), coupons[i].valueAmount!); return S.of(context).percentage_discount_token2(couponDiscountAmount.toStringAsFixed(2), coupons[i].valueAmount!);
} else { } else {
return S.of(context).discount_amount_token(couponDiscountAmount.toStringAsFixed(2)); return S.of(context).discount_amount_token(couponDiscountAmount.toStringAsFixed(2));
@@ -1889,7 +1889,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
mounted) { mounted) {
setState(() { setState(() {
selectedCoupon = coupon.id!; selectedCoupon = coupon.id!;
if (coupon.isPercentage) { if (coupon.isPercentage == true) {
couponDiscountAmount = subtotal * coupon.valueAmount / 100.0; couponDiscountAmount = subtotal * coupon.valueAmount / 100.0;
} else { } else {
couponDiscountAmount = coupon.valueAmount!; couponDiscountAmount = coupon.valueAmount!;

View File

@@ -375,7 +375,7 @@ class MobileViewTicketState extends State<MobileViewTicket> {
); );
} }
if (ticket.isClosed) { if (ticket.isClosed == true) {
view.children.add( view.children.add(
Container( Container(
padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 20.0), padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 20.0),

View File

@@ -508,7 +508,7 @@ class ShopState extends State<Shop>
stack.children.addAll(children); stack.children.addAll(children);
if (!_business.isPublic) { if (_business.isPublic != true) {
stack.children.add( stack.children.add(
Positioned( Positioned(
top: 0, top: 0,
@@ -1821,7 +1821,7 @@ class ShopState extends State<Shop>
return; return;
} }
checkCloseFlag = true; checkCloseFlag = true;
if (business.forceClose) { if (business.forceClose == true) {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {