phase3: nullfix.py batch script — bang/late/param-nullable

Automated null-safety fixes driven by dart analyze (no corruption):
- unchecked_use_of_nullable_value: insert '!' on receiver (property/method/[]/op)
- not_initialized field/var: mark 'late'
- missing_default_value_for_parameter: nullable param
Errors: 2374(peak) -> 907
This commit is contained in:
2026-07-25 18:13:01 +08:00
parent 8f3d3509ea
commit fce670664b
99 changed files with 1013 additions and 838 deletions

View File

@@ -33,18 +33,18 @@ class MobileAttributeSelection extends StatefulWidget {
}
class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
Product product;
int index;
TextButton previousButton;
TextButton nextButton;
bool previousButtonEnable;
bool nextButtonEnable;
late Product product;
late int index;
late TextButton previousButton;
late TextButton nextButton;
late bool previousButtonEnable;
late bool nextButtonEnable;
String productDesc;
double productPrice;
late String productDesc;
late double productPrice;
String nextText;
String finishText;
late String nextText;
late String finishText;
Map<String, dynamic> selections = new Map();
@@ -118,31 +118,31 @@ class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
extendDescription.add(key + ': ' + opt.join(', '));
});
ProductAttribute pa = product.productAttributes[index];
ProductAttribute pa = product.productAttributes![index];
if (pa.required && Utils.selectionsNotEmptyAt(selections, pa.name)) {
setState(() {
nextButtonEnable = true;
productDesc = product.description + ', ' + extendDescription.join('; ');
productPrice = product.price + extendPrice;
productDesc = product.description! + ', ' + extendDescription.join('; ');
productPrice = product.price! + extendPrice;
});
} else if (!pa.required){
setState(() {
nextButtonEnable = true;
productDesc = product.description + ', ' + extendDescription.join('; ');
productPrice = product.price + extendPrice;
productDesc = product.description! + ', ' + extendDescription.join('; ');
productPrice = product.price! + extendPrice;
});
} else {
setState(() {
nextButtonEnable = false;
productDesc = product.description + ', ' + extendDescription.join('; ');
productPrice = product.price + extendPrice;
productDesc = product.description! + ', ' + extendDescription.join('; ');
productPrice = product.price! + extendPrice;
});
}
});
}
bool _checkCanGoNext() {
ProductAttribute pa = product.productAttributes[index];
ProductAttribute pa = product.productAttributes![index];
if (pa.required && Utils.selectionsNotEmptyAt(selections, pa.name)) {
return true;
} else if (!pa.required){
@@ -167,7 +167,7 @@ class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
nextButton = TextButton(
onPressed: nextButtonEnable ? _goNext : null,
child: new Text(
product.productAttributes.length > index + 1 ? nextText : finishText
product.productAttributes!.length > index + 1 ? nextText : finishText
),
);
@@ -239,7 +239,7 @@ class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
Widget _getOptionsView() {
Widget optionsView;
ProductAttribute productAttribute = product.productAttributes[index];
ProductAttribute productAttribute = product.productAttributes![index];
if (productAttribute.byQuantity) {
optionsView = new QtyOptions(product: product, index: index, selections: selections);
} else {
@@ -254,13 +254,13 @@ class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
}
void _goNext() {
if (index + 1 < product.productAttributes.length) {
if (index + 1 < product.productAttributes!.length) {
setState(() {
index = index + 1;
previousButtonEnable = index >= 1;
nextButtonEnable = _checkCanGoNext();
});
} else if (product.productAttributes.length == index + 1) {
} else if (product.productAttributes!.length == index + 1) {
eventBus.fire(new OnProductWillAddToCart(product, selections, productPrice, productDesc, widget.business, buttonKey: widget.startKey));
Navigator.pop(context);
}