From 18abf4eb829e30fa6889fc44d415c164c47cd486 Mon Sep 17 00:00:00 2001 From: peima Date: Fri, 31 Jul 2026 14:57:23 +0800 Subject: [PATCH] phase3: FIX arg-bang regex (missing \] in char class skipped subscripts). 235->183 --- lib/widgets/desktop/desktop_checkout.dart | 10 +++++----- lib/widgets/desktop/desktop_orders.dart | 2 +- .../desktop/desktop_product_detail_page.dart | 2 +- lib/widgets/desktop/shop.dart | 2 +- lib/widgets/desktop/shop_products.dart | 2 +- lib/widgets/desktop/shop_promote.dart | 6 +++--- lib/widgets/general/add_remove_button.dart | 2 +- .../general/attribute/check_options.dart | 18 ++++++++--------- .../general/attribute/qty_options.dart | 20 +++++++++---------- .../general/attribute/radio_options.dart | 14 ++++++------- lib/widgets/mobile/mobile_checkout.dart | 8 ++++---- lib/widgets/mobile/mobile_orders.dart | 2 +- .../mobile/mobile_product_detail_page.dart | 2 +- lib/widgets/mobile/shop.dart | 10 +++++----- tools/nullfix.py | 2 +- 15 files changed, 51 insertions(+), 51 deletions(-) diff --git a/lib/widgets/desktop/desktop_checkout.dart b/lib/widgets/desktop/desktop_checkout.dart index a7c039c..4dfdb4e 100644 --- a/lib/widgets/desktop/desktop_checkout.dart +++ b/lib/widgets/desktop/desktop_checkout.dart @@ -757,7 +757,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi subtotal = 0.0; for (var i = 0; i < cartInfo!.productList!.length; i++) { - subtotal += cartInfo!.productList![i].totalPrice; + subtotal += cartInfo!.productList![i].totalPrice!; column.children.add(lineItem(cartInfo!.productList![i])); } column.children.add(GestureDetector( @@ -863,7 +863,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi Container( alignment: Alignment.centerRight, child: Text( - S.of(context).extra_fee_token(cartInfo!.extraFeeList![i].name, cartInfo!.extraFeeList![i].rate), + S.of(context).extra_fee_token(cartInfo!.extraFeeList![i].name!, cartInfo!.extraFeeList![i].rate!), style: TextStyle( color: Colors.grey, ), @@ -1342,7 +1342,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi child: Container( padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0, bottom: 12.0), child: Text( - bookingDateTime.bookTimes![position].viewTime, + bookingDateTime.bookTimes![position].viewTime!, ), decoration: BoxDecoration( border: Border( @@ -1581,7 +1581,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi for (var i = 0; i < coupons!.length; i++) { if (selectedCoupon == coupons![i].id) { 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 { return S.of(context).discount_amount_token(couponDiscountAmount.toStringAsFixed(2)); } @@ -1957,7 +1957,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi ), )); for (int i = 0; i < cartInfo!.businessInfo!.quickInputs!.length; i++) { - String qi = cartInfo!.businessInfo!.quickInputs![i].value; + String qi = cartInfo!.businessInfo!.quickInputs![i].value!; w.children.add(TextButton( child: Text( qi, diff --git a/lib/widgets/desktop/desktop_orders.dart b/lib/widgets/desktop/desktop_orders.dart index a7301e8..1a89b1e 100644 --- a/lib/widgets/desktop/desktop_orders.dart +++ b/lib/widgets/desktop/desktop_orders.dart @@ -181,7 +181,7 @@ class DesktopOrdersState extends State with SingleTickerProviderS row.children.add(Expanded( child: Container( child: Text( - order!.cartInfo!.productList![0].name, + order!.cartInfo!.productList![0].name!, style: TextStyle( fontSize: 14.0, ), diff --git a/lib/widgets/desktop/desktop_product_detail_page.dart b/lib/widgets/desktop/desktop_product_detail_page.dart index 2a0eec3..b2e8538 100644 --- a/lib/widgets/desktop/desktop_product_detail_page.dart +++ b/lib/widgets/desktop/desktop_product_detail_page.dart @@ -455,7 +455,7 @@ class DesktopProductDetailPageState extends State images.add(productDetail.image!); for (var i = 0; i < productDetail.images!.length; i++) { // print('>>https:' + productDetail.images[i].image); - images.add(productDetail.images![i].image); + images.add(productDetail.images![i].image!); } for (var i = 0; i < images.length; i++) { diff --git a/lib/widgets/desktop/shop.dart b/lib/widgets/desktop/shop.dart index 80c9e75..bd32ac6 100644 --- a/lib/widgets/desktop/shop.dart +++ b/lib/widgets/desktop/shop.dart @@ -223,7 +223,7 @@ class ShopState extends State { .map((i) => CategoryProducts.fromJson(i)) .toList(); if (categoryId == 0 && displayProductByCategoryClick) { - categoryId = _categoryProducts[0].id; + categoryId = _categoryProducts[0].id!; } data = value; }); diff --git a/lib/widgets/desktop/shop_products.dart b/lib/widgets/desktop/shop_products.dart index 2073544..f9c71f8 100644 --- a/lib/widgets/desktop/shop_products.dart +++ b/lib/widgets/desktop/shop_products.dart @@ -347,7 +347,7 @@ class ShopProductsState extends State { } displayProductByCategoryClickIndicator = ''; if (categoryId == 0 && displayProductByCategoryClick) { - categoryId = _categoryProducts[0].id; + categoryId = _categoryProducts[0].id!; } setState(() { diff --git a/lib/widgets/desktop/shop_promote.dart b/lib/widgets/desktop/shop_promote.dart index 0971f94..22fc9a4 100644 --- a/lib/widgets/desktop/shop_promote.dart +++ b/lib/widgets/desktop/shop_promote.dart @@ -129,7 +129,7 @@ class ShopPromoteState extends State { GestureDetector( child: Container( child: Util.showImage( - _business.promoProducts![i].imagePath, + _business.promoProducts![i].imagePath!, width: 120.0, ), ), @@ -139,7 +139,7 @@ class ShopPromoteState extends State { ), Container( child: Text( - _business.promoProducts![i].name, + _business.promoProducts![i].name!, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 14.0), @@ -149,7 +149,7 @@ class ShopPromoteState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ ShowPrice( - _business.promoProducts![i].price, + _business.promoProducts![i].price!, currencySign: '\$', fontWeight: FontWeight.bold, smallFontSize: 15, diff --git a/lib/widgets/general/add_remove_button.dart b/lib/widgets/general/add_remove_button.dart index eaf64b0..85527a8 100644 --- a/lib/widgets/general/add_remove_button.dart +++ b/lib/widgets/general/add_remove_button.dart @@ -380,7 +380,7 @@ class AddRemoveButtonState extends State { void _removeCartLineItem() { if (cartInfo.productList![widget.cartLineItemIndex].quantity! <= 1) { - String uuid = cartInfo.productList![widget.cartLineItemIndex].uuid; + String uuid = cartInfo.productList![widget.cartLineItemIndex].uuid!; cartInfo.productList!.removeAt(widget.cartLineItemIndex); Utils.removeSubproduct(cartInfo, uuid); } else { diff --git a/lib/widgets/general/attribute/check_options.dart b/lib/widgets/general/attribute/check_options.dart index 286235b..e94e1b2 100644 --- a/lib/widgets/general/attribute/check_options.dart +++ b/lib/widgets/general/attribute/check_options.dart @@ -50,7 +50,7 @@ class CheckOptionsState extends OptionsBaseState { crossAxisAlignment: CrossAxisAlignment.start, children: [ new Text( - S.of(context).check_option_select_token(product.productAttributes![this.index].name), + S.of(context).check_option_select_token(product.productAttributes![this.index].name!), style: new TextStyle( fontSize: 12.5, ), @@ -95,7 +95,7 @@ class CheckOptionsState extends OptionsBaseState { 'adjust_amount': adjustAmount }; var cloneSelections = json.decode(json.encode(selections)); - int idx = Utils.selectionsContains(cloneSelections, product.productAttributes![index].name, name); + int idx = Utils.selectionsContains(cloneSelections, product.productAttributes![index].name!, name); if (idx != -1) { (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).removeAt(idx); } else if (cloneSelections.containsKey(product.productAttributes![index].name!.toUpperCase())) { @@ -108,7 +108,7 @@ class CheckOptionsState extends OptionsBaseState { cloneSelections.remove(product.productAttributes![index].name!.toUpperCase()); } - setOptionsStateDisabled(product.productAttributes![index].name, false); + setOptionsStateDisabled(product.productAttributes![index].name!, false); setState(() { selections = cloneSelections; @@ -121,14 +121,14 @@ class CheckOptionsState extends OptionsBaseState { children: [], ); - List productOptions = product.productAttributes![index].productOptions; + List productOptions = product.productAttributes![index].productOptions!; if (!optionsState.containsKey(product.productAttributes![index].name)) { List> optionState = []; for (var i = 0; i < productOptions.length; i++) { optionState.add({'name': product.productAttributes![index].productOptions![i].name, 'disabled': false, 'check': false}); } - optionsState[product.productAttributes![index].name] = optionState; + optionsState[product.productAttributes![index].name!] = optionState; } if (selections.containsKey(product.productAttributes![index].name!.toUpperCase())) { @@ -199,7 +199,7 @@ class CheckOptionsState extends OptionsBaseState { } else { if (_checkOptionIsCheck(productOptions[i].name!)) { setOptionsStateDisabled( - product.productAttributes![index].name, true); + product.productAttributes![index].name!, true); optionsState[product.productAttributes![index] .name][i]['disabled'] = false; break; @@ -232,16 +232,16 @@ class CheckOptionsState extends OptionsBaseState { } void disableOptionIfNotSelected() { - setOptionsStateDisabled(product.productAttributes![index].name, true); + setOptionsStateDisabled(product.productAttributes![index].name!, true); for (var i = 0; i < optionsState[product.productAttributes![index].name].length; i++) { - if (Utils.selectionsContains(selections, product.productAttributes![index].name, optionsState[product.productAttributes![index].name][i]['name']) != -1) { + if (Utils.selectionsContains(selections, product.productAttributes![index].name!, optionsState[product.productAttributes![index].name][i]['name']) != -1) { optionsState[product.productAttributes![index].name][i]['disabled'] = false; } } } bool _checkOptionIsCheck(String name) { - if (Utils.selectionsContains(selections, product.productAttributes![index].name, name) != -1) { + if (Utils.selectionsContains(selections, product.productAttributes![index].name!, name) != -1) { return true; } return false; diff --git a/lib/widgets/general/attribute/qty_options.dart b/lib/widgets/general/attribute/qty_options.dart index 62206a1..6482103 100644 --- a/lib/widgets/general/attribute/qty_options.dart +++ b/lib/widgets/general/attribute/qty_options.dart @@ -41,7 +41,7 @@ class QtyOptionsState extends OptionsBaseState { crossAxisAlignment: CrossAxisAlignment.start, children: [ new Text( - S.of(context).check_option_select_token(product.productAttributes![this.index].name), + S.of(context).check_option_select_token(product.productAttributes![this.index].name!), style: new TextStyle( fontSize: 12.5, ), @@ -86,7 +86,7 @@ class QtyOptionsState extends OptionsBaseState { 'adjust_amount': adjustAmount }; var cloneSelections = json.decode(json.encode(selections)); - int idx = Utils.selectionsContains(cloneSelections, product.productAttributes![index].name, name); + int idx = Utils.selectionsContains(cloneSelections, product.productAttributes![index].name!, name); if (idx != -1) { if (quantity == 1) { cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'] += 1; @@ -112,7 +112,7 @@ class QtyOptionsState extends OptionsBaseState { cloneSelections.remove(product.productAttributes![index].name!.toUpperCase()); } - setOptionsStateDisabled(product.productAttributes![index].name, false); + setOptionsStateDisabled(product.productAttributes![index].name!, false); setState(() { selections = cloneSelections; @@ -125,19 +125,19 @@ class QtyOptionsState extends OptionsBaseState { children: [], ); - List productOptions = product.productAttributes![index].productOptions; + List productOptions = product.productAttributes![index].productOptions!; if (!optionsState.containsKey(product.productAttributes![index].name)) { List> optionState = []; for (var i = 0; i < productOptions.length; i++) { int qty = 0; - int idx = Utils.selectionsContains(selections, product.productAttributes![index].name, productOptions[i].name!); + int idx = Utils.selectionsContains(selections, product.productAttributes![index].name!, productOptions[i].name!); if (idx != -1) { qty = selections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity']; } optionState.add({'name': product.productAttributes![index].productOptions![i].name, 'disabled': false, 'quantity': qty, 'check': false}); } - optionsState[product.productAttributes![index].name] = optionState; + optionsState[product.productAttributes![index].name!] = optionState; } if (selections.containsKey(product.productAttributes![index].name!.toUpperCase())) { @@ -207,7 +207,7 @@ class QtyOptionsState extends OptionsBaseState { } else { if (_checkOptionIsCheck(productOptions[i].name!)) { setOptionsStateDisabled( - product.productAttributes![index].name, true); + product.productAttributes![index].name!, true); optionsState[product.productAttributes![index] .name][i]['disabled'] = false; break; @@ -240,16 +240,16 @@ class QtyOptionsState extends OptionsBaseState { } void disableOptionIfNotSelected() { - setOptionsStateDisabled(product.productAttributes![index].name, true); + setOptionsStateDisabled(product.productAttributes![index].name!, true); for (var i = 0; i < optionsState[product.productAttributes![index].name].length; i++) { - if (Utils.selectionsContains(selections, product.productAttributes![index].name, optionsState[product.productAttributes![index].name][i]['name']) != -1) { + if (Utils.selectionsContains(selections, product.productAttributes![index].name!, optionsState[product.productAttributes![index].name][i]['name']) != -1) { optionsState[product.productAttributes![index].name][i]['disabled'] = false; } } } bool _checkOptionIsCheck(String name) { - if (Utils.selectionsContains(selections, product.productAttributes![index].name, name) != -1) { + if (Utils.selectionsContains(selections, product.productAttributes![index].name!, name) != -1) { return true; } return false; diff --git a/lib/widgets/general/attribute/radio_options.dart b/lib/widgets/general/attribute/radio_options.dart index cf11914..5d1e289 100644 --- a/lib/widgets/general/attribute/radio_options.dart +++ b/lib/widgets/general/attribute/radio_options.dart @@ -40,7 +40,7 @@ class RadioOptionsState extends OptionsBaseState { crossAxisAlignment: CrossAxisAlignment.start, children: [ new Text( - S.of(context).radio_option_select_token(product.productAttributes![this.index].name), + S.of(context).radio_option_select_token(product.productAttributes![this.index].name!), style: new TextStyle( fontSize: 12.5, ), @@ -102,7 +102,7 @@ class RadioOptionsState extends OptionsBaseState { extraJson, Rule.RULE_EXCLUSIVE_SELECTION); if (exclusiveRule != null) { if (_checkOptionIsCheck(productOption.name!)) { - setOptionsStateDisabled(product.productAttributes![index].name, false); + setOptionsStateDisabled(product.productAttributes![index].name!, false); } } } @@ -118,24 +118,24 @@ class RadioOptionsState extends OptionsBaseState { children: [], ); - List productOptions = product.productAttributes![index].productOptions; + List productOptions = product.productAttributes![index].productOptions!; if (!optionsState.containsKey(product.productAttributes![index].name)) { List> optionState = []; for (var i = 0; i < productOptions.length; i++) { optionState.add({'name': product.productAttributes![index].productOptions![i].name, 'disabled': false, 'check': false}); } - optionsState[product.productAttributes![index].name] = optionState; + optionsState[product.productAttributes![index].name!] = optionState; } for (var i = 0; i < productOptions.length; i++) { - Map extraJson = Utils.stringToJson(productOptions[i].extra!); + Map extraJson = Utils.stringToJson(productOptions[i].extra!)!; if (extraJson != null) { Map exclusiveRule = Rule.getRule( extraJson, Rule.RULE_EXCLUSIVE_SELECTION); if (exclusiveRule != null) { if (_checkOptionIsCheck(productOptions[i].name!)) { - setOptionsStateDisabled(product.productAttributes![index].name, true); + setOptionsStateDisabled(product.productAttributes![index].name!, true); optionsState[product.productAttributes![index].name][i]['disabled'] = false; break; } @@ -153,7 +153,7 @@ class RadioOptionsState extends OptionsBaseState { } bool _checkOptionIsCheck(String name) { - if (Utils.selectionsContains(selections, product.productAttributes![index].name, name) != -1) { + if (Utils.selectionsContains(selections, product.productAttributes![index].name!, name) != -1) { return true; } return false; diff --git a/lib/widgets/mobile/mobile_checkout.dart b/lib/widgets/mobile/mobile_checkout.dart index 8ffcf7c..fa495c6 100644 --- a/lib/widgets/mobile/mobile_checkout.dart +++ b/lib/widgets/mobile/mobile_checkout.dart @@ -732,7 +732,7 @@ class MobileCheckoutState extends State with SingleTickerProvide subtotal = 0.0; for (var i = 0; i < cartInfo.productList!.length; i++) { - subtotal += cartInfo.productList![i].totalPrice; + subtotal += cartInfo.productList![i].totalPrice!; column.children.add(lineItem(cartInfo.productList![i])); } column.children.add(GestureDetector( @@ -838,7 +838,7 @@ class MobileCheckoutState extends State with SingleTickerProvide Container( alignment: Alignment.centerRight, child: Text( - S.of(context).extra_fee_token(cartInfo.extraFeeList![i].name, cartInfo.extraFeeList![i].rate), + S.of(context).extra_fee_token(cartInfo.extraFeeList![i].name!, cartInfo.extraFeeList![i].rate!), style: TextStyle( color: Colors.grey, ), @@ -1317,7 +1317,7 @@ class MobileCheckoutState extends State with SingleTickerProvide child: Container( padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0, bottom: 12.0), child: Text( - bookingDateTime.bookTimes![position].viewTime, + bookingDateTime.bookTimes![position].viewTime!, ), decoration: BoxDecoration( border: Border( @@ -1932,7 +1932,7 @@ class MobileCheckoutState extends State with SingleTickerProvide ), )); for (int i = 0; i < cartInfo.businessInfo!.quickInputs!.length; i++) { - String qi = cartInfo.businessInfo!.quickInputs![i].value; + String qi = cartInfo.businessInfo!.quickInputs![i].value!; w.children.add(TextButton( child: Text( qi, diff --git a/lib/widgets/mobile/mobile_orders.dart b/lib/widgets/mobile/mobile_orders.dart index c74b2d6..87ea868 100644 --- a/lib/widgets/mobile/mobile_orders.dart +++ b/lib/widgets/mobile/mobile_orders.dart @@ -152,7 +152,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta row.children.add(Expanded( child: Container( child: Text( - order.cartInfo!.productList![0].name, + order.cartInfo!.productList![0].name!, style: TextStyle( fontSize: 14.0, ), diff --git a/lib/widgets/mobile/mobile_product_detail_page.dart b/lib/widgets/mobile/mobile_product_detail_page.dart index c8ccab7..00e9ae5 100644 --- a/lib/widgets/mobile/mobile_product_detail_page.dart +++ b/lib/widgets/mobile/mobile_product_detail_page.dart @@ -421,7 +421,7 @@ class MobileProductDetailPageState extends State images.add(productDetail.image!); for (var i = 0; i < productDetail.images!.length; i++) { // print('>>https:' + productDetail.images[i].image); - images.add(productDetail.images![i].image); + images.add(productDetail.images![i].image!); } for (var i = 0; i < images.length; i++) { diff --git a/lib/widgets/mobile/shop.dart b/lib/widgets/mobile/shop.dart index da4f77a..e49b499 100644 --- a/lib/widgets/mobile/shop.dart +++ b/lib/widgets/mobile/shop.dart @@ -286,7 +286,7 @@ class ShopState extends State GestureDetector( child: Container( child: Util.showImage( - _business.promoProducts![i].imagePath, + _business.promoProducts![i].imagePath!, width: 110.0, ), ), @@ -296,7 +296,7 @@ class ShopState extends State ), Container( child: Text( - _business.promoProducts![i].name, + _business.promoProducts![i].name!, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 14.0), @@ -306,7 +306,7 @@ class ShopState extends State mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ ShowPrice( - _business.promoProducts![i].price, + _business.promoProducts![i].price!, currencySign: '\$', regularPrice: _business.promoProducts![i].regularPrice, ), @@ -1102,7 +1102,7 @@ class ShopState extends State pages.add(new GestureDetector( child: new Container( child: Util.showImage( - _business.slideImages![i].imageUrl, + _business.slideImages![i].imageUrl!, fit: BoxFit.cover, ), ), @@ -1214,7 +1214,7 @@ class ShopState extends State void _selectCategory(int index) { if (displayProductByCategoryClick && _categoryProducts[index].id! > 0) { - categoryId = _categoryProducts[index].id; + categoryId = _categoryProducts[index].id!; loadProducts(); return; } diff --git a/tools/nullfix.py b/tools/nullfix.py index d2250a6..b46c938 100644 --- a/tools/nullfix.py +++ b/tools/nullfix.py @@ -132,7 +132,7 @@ def insert_arg_bang(line, col0): if not val: return None if val[0] in '0123456789"\'': return None # 字面量跳过 if val in ('true','false','null'): return None - if not re.fullmatch(r'[\w.\[\()!]+', val): return None # 含运算符/空格跳过 + if not re.fullmatch(r'[\w.\[\]()!]+', val): return None # 含运算符/空格跳过 return line[:j+1]+'!'+line[j+1:] def make_field_nullable(lines, name):