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

@@ -35,21 +35,21 @@ class ShoppingCartBar extends StatefulWidget {
}
class ShoppingCartBarState extends State<ShoppingCartBar> {
CartInfo cartInfo;
late CartInfo cartInfo;
double totalPrice = 0.0;
@override
Widget build(BuildContext context) {
totalPrice = 0.0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
if (cartInfo != null && cartInfo.businessInfo.id == widget.business.id) {
if (cartInfo != null && cartInfo.businessInfo!.id == widget.business.id) {
totalPrice = cartInfo.getTotalPrice();
}
Widget cartContent;
if (cartInfo == null || (cartInfo.businessInfo.id != widget.business.id)
|| (totalPrice == 0.0 && cartInfo.productList.length == 0)) {
if (cartInfo == null || (cartInfo.businessInfo!.id != widget.business.id)
|| (totalPrice == 0.0 && cartInfo.productList!.length == 0)) {
cartContent = Center(
child: Container(
padding: EdgeInsets.all(20.0),
@@ -92,8 +92,8 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
},
),
);
for (var i = 0; i < cartInfo.productList.length; i++) {
(cartContent as Column).children.add(cartLineItem(cartInfo.productList[i], i));
for (var i = 0; i < cartInfo.productList!.length; i++) {
(cartContent as Column).children.add(cartLineItem(cartInfo.productList![i], i));
}
}
@@ -134,7 +134,7 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
],
),
new Text(
S.of(context).delivery_fee(widget.business.shippingFee.toStringAsFixed(2)),
S.of(context).delivery_fee(widget.business.shippingFee!.toStringAsFixed(2)),
style: new TextStyle(
fontSize: 9.0,
color: Style.backgroundColor,
@@ -149,10 +149,10 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
child: GestureDetector(
child: Container(
padding: EdgeInsets.all(10.0),
color: widget.business.minPrice - totalPrice >= 0 ? new Color(0xFF535356) : Colors.lightGreen,
color: widget.business.minPrice! - totalPrice >= 0 ? new Color(0xFF535356) : Colors.lightGreen,
child: Center(
child: Text(
widget.business.minPrice - totalPrice >= 0 ? S.of(context).order_more((widget.business.minPrice - totalPrice).toStringAsFixed(2)) : S.of(context).checkout,
widget.business.minPrice! - totalPrice >= 0 ? S.of(context).order_more((widget.business.minPrice! - totalPrice).toStringAsFixed(2)) : S.of(context).checkout,
style: TextStyle(
fontSize: 14.0,
color: Style.backgroundColor,
@@ -160,7 +160,7 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
),
),
),
onTap: widget.business.minPrice >= totalPrice ? null : () {
onTap: widget.business.minPrice! >= totalPrice ? null : () {
if (store.state.user != null) {
Routes.router.navigateTo(context, '/checkout/${widget.business.id}');
} else {
@@ -255,7 +255,7 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
widget.hasPicture ? Container(
padding: EdgeInsets.all(6.0),
child: Util.showImage(
'${item.product.imagePath}',
'${item.product!.imagePath}',
width: 80,
height: 80,
fit: BoxFit.cover,
@@ -300,7 +300,7 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
children: <Widget>[
Container(
child: Text(
'${item.totalPrice.toStringAsFixed(2)}',
'${item.totalPrice!.toStringAsFixed(2)}',
style: TextStyle(
color: Colors.redAccent,
fontSize: 14.0,