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

@@ -40,7 +40,7 @@ class AddRemoveButton extends StatefulWidget {
}
class AddRemoveButtonState extends State<AddRemoveButton> {
int _qty;
late int _qty;
var zeroColor = const Color(0xFFEFEFEF);
var qtyColor = const Color(0xFFFF6666);
var zeroFontColor = const Color(0xFF888888);
@@ -48,7 +48,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
var d = 1;
CartInfo cartInfo;
late CartInfo cartInfo;
GlobalKey startKey = GlobalKey();
@@ -63,10 +63,10 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
_qty = 0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
if (cartInfo != null) {
for (var i = 0; i < cartInfo.productList.length; i++) {
if (cartInfo.productList[i].product.id == widget.product.id
&& cartInfo.productList[i].unitPrice == 0.0) {
_qty = cartInfo.productList[i].quantity.round();
for (var i = 0; i < cartInfo.productList!.length; i++) {
if (cartInfo.productList![i].product!.id == widget.product.id
&& cartInfo.productList![i].unitPrice == 0.0) {
_qty = cartInfo.productList![i].quantity!.round();
break;
}
}
@@ -78,7 +78,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
),
);
}
if (widget.product.leftNum <= 0) {
if (widget.product.leftNum! <= 0) {
return Container(
padding: EdgeInsets.only(top: 0.0, bottom: 10.0, left: 8.0, right: 8.0),
child: Text(
@@ -104,9 +104,9 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
_qty = 0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
if (cartInfo != null) {
for (var i = 0; i < cartInfo.productList.length; i++) {
if (cartInfo.productList[i].product.id == widget.product.id) {
_qty = cartInfo.productList[i].quantity.round();
for (var i = 0; i < cartInfo.productList!.length; i++) {
if (cartInfo.productList![i].product!.id == widget.product.id) {
_qty = cartInfo.productList![i].quantity!.round();
break;
}
}
@@ -197,15 +197,15 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
_qty = 0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
if (cartInfo != null) {
for (var i = 0; i < cartInfo.productList.length; i++) {
if (cartInfo.productList[i].product.id == widget.product.id) {
_qty = cartInfo.productList[i].quantity.round();
for (var i = 0; i < cartInfo.productList!.length; i++) {
if (cartInfo.productList![i].product!.id == widget.product.id) {
_qty = cartInfo.productList![i].quantity!.round();
break;
}
}
}
if (widget.product.productAttributes != null &&
widget.product.productAttributes.length > 0 && widget.cartLineItemIndex == -1) {
widget.product.productAttributes!.length > 0 && widget.cartLineItemIndex == -1) {
return new Row(
key: startKey,
crossAxisAlignment: CrossAxisAlignment.end,
@@ -312,7 +312,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
void _addToCart(BuildContext context) {
if (widget.cartLineItemIndex != -1) {
if (cartInfo.productList[widget.cartLineItemIndex].quantity + 1.0 > widget.product.leftNum) {
if (cartInfo.productList![widget.cartLineItemIndex].quantity! + 1.0 > widget.product.leftNum) {
Fluttertoast.showToast(
msg: S.of(context).product_insufficient,
toastLength: Toast.LENGTH_SHORT,
@@ -321,14 +321,14 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
textColor: Colors.white
);
} else {
cartInfo.productList[widget.cartLineItemIndex].quantity += 1.0;
Utils.addSubproductQty(cartInfo, cartInfo.productList[widget.cartLineItemIndex]);
cartInfo.productList![widget.cartLineItemIndex].quantity += 1.0;
Utils.addSubproductQty(cartInfo, cartInfo.productList![widget.cartLineItemIndex]);
store.dispatch(UpdateCartInfo(
Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));
eventBus.fire(new OnCartInfoUpdated());
}
} else {
if (widget.product.productAttributes.length > 0) {
if (widget.product.productAttributes!.length > 0) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) =>
@@ -345,7 +345,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
void _removeFromCart(BuildContext context) {
if (widget.cartLineItemIndex != -1) {
if (cartInfo.productList[widget.cartLineItemIndex].quantity <= 1) {
if (cartInfo.productList![widget.cartLineItemIndex].quantity! <= 1) {
showDialog(
context: context,
builder: (BuildContext context) {
@@ -380,15 +380,15 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
}
void _removeCartLineItem() {
if (cartInfo.productList[widget.cartLineItemIndex].quantity <= 1) {
String uuid = cartInfo.productList[widget.cartLineItemIndex].uuid;
cartInfo.productList.removeAt(widget.cartLineItemIndex);
if (cartInfo.productList![widget.cartLineItemIndex].quantity! <= 1) {
String uuid = cartInfo.productList![widget.cartLineItemIndex].uuid;
cartInfo.productList!.removeAt(widget.cartLineItemIndex);
Utils.removeSubproduct(cartInfo, uuid);
} else {
cartInfo.productList[widget.cartLineItemIndex].quantity -= 1;
Utils.addSubproductQty(cartInfo, cartInfo.productList[widget.cartLineItemIndex], remove: true);
cartInfo.productList![widget.cartLineItemIndex].quantity -= 1;
Utils.addSubproductQty(cartInfo, cartInfo.productList![widget.cartLineItemIndex], remove: true);
}
if (cartInfo.productList.length <= 0) {
if (cartInfo.productList!.length <= 0) {
store.dispatch(new UpdateCartInfo(Utils.removeCartInfoFromCartInfoList(store.state.cartInfos, cartInfo)));
} else {
store.dispatch(new UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));