phase3: nullable fields/methods, casts, ?.call, pinput/YoutubePlayer v5, buttonColor, dead-code removal. 72->16

This commit is contained in:
2026-08-01 01:21:37 +08:00
parent 137eca4c69
commit 7c69197396
39 changed files with 107 additions and 113 deletions

View File

@@ -40,7 +40,7 @@ class CreateOnlineStore1State extends State<CreateOnlineStore1> {
late Group group;
late String selectedDomain;
String? selectedDomain;
List<dynamic> domainResult = [];
@override

View File

@@ -34,7 +34,7 @@ class DesktopBlog extends StatefulWidget {
}
class DesktopBlogState extends State<DesktopBlog> {
late List<Blog> blogs;
List<Blog>? blogs;
double division = 2;
@@ -49,7 +49,7 @@ class DesktopBlogState extends State<DesktopBlog> {
void _onRefresh() {
_page = 1;
if (blogs != null) {
blogs.clear();
blogs!.clear();
} else {
blogs = [];
}
@@ -98,7 +98,7 @@ class DesktopBlogState extends State<DesktopBlog> {
enablePullUp: true,
header: WaterDropHeader(),
footer: CustomFooter(
builder: (BuildContext context, LoadStatus mode){
builder: (BuildContext context, LoadStatus? mode){
Widget footer;
if(mode == LoadStatus.idle) {
footer = Text(S.of(context).pull_up_to_load_more);
@@ -148,9 +148,9 @@ class DesktopBlogState extends State<DesktopBlog> {
right: 8.0,
),
child: blogs == null ? Text('') :
(blogs.length > 0 ?
(blogs!.length > 0 ?
Wrap(
children: blogs.map((a) => GestureDetector(
children: blogs!.map((a) => GestureDetector(
child: _getBlog(a),
onTap: () {
Routes.router.navigateTo(context, '/view-blog/${a.id}');
@@ -293,7 +293,7 @@ class DesktopBlogState extends State<DesktopBlog> {
if (blogs == null) {
blogs = [];
}
blogs.addAll((value['blogs'] as List).map((e) => Blog.fromJson(e)).toList());
blogs!.addAll((value['blogs'] as List).map((e) => Blog.fromJson(e)).toList());
});
}
}).catchError((error) {

View File

@@ -112,7 +112,7 @@ class DesktopiGoShowLearnMoreState extends State<DesktopiGoShowLearnMore> {
),
child: ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: YoutubePlayerIFrame(
child: YoutubePlayer(
controller: _controller,
aspectRatio: 1.7778,
),

View File

@@ -30,7 +30,7 @@ class DesktopMyAddresses extends StatefulWidget {
}
class DesktopMyAddressesState extends State<DesktopMyAddresses> {
late List<Address> addresses;
List<Address>? addresses;
double sideSpace = 0;
double mainSpace = 1200;
@@ -91,9 +91,9 @@ class DesktopMyAddressesState extends State<DesktopMyAddresses> {
right: 8.0,
),
child: addresses == null ? Text('') :
(addresses.length > 0 ?
(addresses!.length > 0 ?
Wrap(
children: addresses.map((a) => _getAddress(a)).toList(),
children: addresses!.map((a) => _getAddress(a)).toList(),
) :
Center(
child: Text(S.of(context).no_address_yet),

View File

@@ -353,7 +353,7 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
),
bottomNavigationBar: Container(
padding: EdgeInsets.all(8.0),
color: Theme.of(context).buttonColor,
color: Theme.of(context).colorScheme.primary,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[

View File

@@ -306,7 +306,7 @@ class DesktopNewCommentState extends State<DesktopNewComment> {
barrierDismissible: true,
builder: (BuildContext context) {
return Util().getPicture(mainContext, store.state.user!,
commentId: comment != null ? comment.id : 0,
commentId: comment != null ? comment.id! : 0,
orderId: widget.orderId);
}
);
@@ -365,7 +365,7 @@ class DesktopNewCommentState extends State<DesktopNewComment> {
}
},
queryParameters: {
'comment_id': comment != null ? comment.id : 0,
'comment_id': comment != null ? comment.id! : 0,
},
).catchError((error) {
Utils.showMessageDialog(context, error);
@@ -392,7 +392,7 @@ class DesktopNewCommentState extends State<DesktopNewComment> {
isFormData: true,
body: {
'order_id': widget.orderId,
'comment_id': comment != null ? comment.id : 0,
'comment_id': comment != null ? comment.id! : 0,
'content': commentController.text,
'rating': rating.round(),
},

View File

@@ -357,7 +357,6 @@ class DesktopNewTicketState extends State<DesktopNewTicket> {
galleryImagesFlag[imageId]['path'] = path;
});
});
return null;
}
);
},

View File

@@ -35,7 +35,7 @@ class DesktopOrders extends StatefulWidget {
class DesktopOrdersState extends State<DesktopOrders> with SingleTickerProviderStateMixin {
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
late List<Order> orders;
List<Order>? orders;
bool _isLoading = false;
@@ -132,14 +132,14 @@ class DesktopOrdersState extends State<DesktopOrders> with SingleTickerProviderS
return ListView.builder(
controller: scrollController,
itemCount: orders != null && orders.length > 0 ? orders.length + 1 : 1,
itemCount: orders != null && orders!.length > 0 ? orders!.length + 1 : 1,
itemBuilder: (BuildContext context, int position) {
Order? order;
if (orders != null && orders.length > 0 && position < orders.length) {
order = orders[position];
if (orders != null && orders!.length > 0 && position < orders!.length) {
order = orders![position];
}
if (order == null && orders.length <= 0) {
if (order == null && orders!.length <= 0) {
return Container(
padding: EdgeInsets.all(16.0),
child: Center(
@@ -148,7 +148,7 @@ class DesktopOrdersState extends State<DesktopOrders> with SingleTickerProviderS
),
),
);
} else if (position >= orders.length) {
} else if (position >= orders!.length) {
if (_pageCount > _page) {
return Container(
padding: EdgeInsets.all(16.0),
@@ -228,7 +228,7 @@ class DesktopOrdersState extends State<DesktopOrders> with SingleTickerProviderS
),
],
);
if (order!.status == Constants.STATUS_COMPLETE && !order!.hasComment) {
if (order!.status == Constants.STATUS_COMPLETE && order!.hasComment != true) {
row3.children.add(
Padding(
padding: EdgeInsets.only(left: 10.0),
@@ -458,7 +458,7 @@ class DesktopOrdersState extends State<DesktopOrders> with SingleTickerProviderS
if (orders == null) {
orders = [];
}
orders.addAll((data['items'] as List).map((e) => Order.fromJson(e)).toList());
orders!.addAll((data['items'] as List).map((e) => Order.fromJson(e)).toList());
});
}
}).catchError((error) {

View File

@@ -107,7 +107,7 @@ class DesktopProductItemState extends State<DesktopProductItem> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Container(
child: widget.business!.showMonthlySold ?
child: widget.business!.showMonthlySold == true ?
Text(
S.of(context).sold_per_month_token(widget.product!.monthSales!.toStringAsFixed(0)),
style: new TextStyle(
@@ -191,7 +191,7 @@ class DesktopProductItemState extends State<DesktopProductItem> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Container(
child: widget.business!.showMonthlySold ?
child: widget.business!.showMonthlySold == true ?
Text(
S.of(context).sold_per_month_token(widget.product!.monthSales!.toStringAsFixed(0)),
style: new TextStyle(

View File

@@ -144,7 +144,7 @@ class DesktopSearchPlaceState extends State<DesktopSearchPlace> {
Navigator.of(context).pop();
}
void _selectPlaceAsNew(LocatedAddress locatedAddress) {
void _selectPlaceAsNew(LocatedAddress? locatedAddress) {
print('located address: ${locatedAddress.toString()}');
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) => NewAddress(locatedAddress: locatedAddress, businessId: widget.businessId,),

View File

@@ -24,7 +24,7 @@ class DesktopShoppingCartWidgetState extends State<DesktopShoppingCartWidget> {
@override
Widget build(BuildContext context) {
totalPrice = 0.0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business)!;
if (cartInfo != null && cartInfo.businessInfo!.id == widget.business.id) {
totalPrice = cartInfo.getTotalPrice();
}
@@ -59,7 +59,7 @@ class DesktopShoppingCartWidgetState extends State<DesktopShoppingCartWidget> {
child: row,
width: 160.0,
),
onTap: widget.onTap!,
onTap: () => widget.onTap!(),
),
);
}

View File

@@ -601,7 +601,6 @@ class DesktopViewTicketState extends State<DesktopViewTicket> {
galleryImagesFlag[imageId]['path'] = path;
});
});
return null;
}
);
},

View File

@@ -141,7 +141,7 @@ class ProductItemState extends State<ProductItem> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Container(
child: widget.business.showMonthlySold ?
child: widget.business.showMonthlySold == true ?
Text(
S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)),
style: new TextStyle(
@@ -229,7 +229,7 @@ class ProductItemState extends State<ProductItem> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Container(
child: widget.business.showMonthlySold ?
child: widget.business.showMonthlySold == true ?
Text(
S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)),
style: new TextStyle(

View File

@@ -286,7 +286,7 @@ class ShopState extends State<Shop> {
if (_categoryProducts[i].id == currentCategoryId) {
try {
CategoryProducts cps = _categoryProducts[i + 1];
return cps.id;
return cps.id!;
} catch (error) {
print('Error $error');
}

View File

@@ -25,7 +25,7 @@ class ShoppingCartWidgetState extends State<ShoppingCartWidget> {
@override
Widget build(BuildContext context) {
totalPrice = 0.0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business)!;
if (cartInfo != null && cartInfo.businessInfo!.id == widget.business.id) {
totalPrice = cartInfo.getTotalPrice();
}
@@ -60,7 +60,7 @@ class ShoppingCartWidgetState extends State<ShoppingCartWidget> {
child: row,
width: 160.0,
),
onTap: widget.onTap!,
onTap: () => widget.onTap!(),
),
);
}