From 7c69197396223682b0d8ae28aba38e875507a94a Mon Sep 17 00:00:00 2001 From: peima Date: Sat, 1 Aug 2026 01:21:37 +0800 Subject: [PATCH] phase3: nullable fields/methods, casts, ?.call, pinput/YoutubePlayer v5, buttonColor, dead-code removal. 72->16 --- lib/pages/shop.dart | 2 +- lib/store/actions.dart | 2 +- .../desktop/create_online_store_1.dart | 2 +- lib/widgets/desktop/desktop_blog.dart | 12 +++++------ .../desktop/desktop_igoshow_learn_more.dart | 2 +- lib/widgets/desktop/desktop_my_addresses.dart | 6 +++--- lib/widgets/desktop/desktop_new_address.dart | 2 +- lib/widgets/desktop/desktop_new_comment.dart | 6 +++--- lib/widgets/desktop/desktop_new_ticket.dart | 1 - lib/widgets/desktop/desktop_orders.dart | 16 +++++++-------- lib/widgets/desktop/desktop_product_item.dart | 4 ++-- lib/widgets/desktop/desktop_search_place.dart | 2 +- .../desktop/desktop_shopping_cart_widget.dart | 4 ++-- lib/widgets/desktop/desktop_view_ticket.dart | 1 - lib/widgets/desktop/product_item.dart | 4 ++-- lib/widgets/desktop/shop.dart | 2 +- lib/widgets/desktop/shopping_cart_widget.dart | 4 ++-- lib/widgets/general/add_remove_button.dart | 6 +++--- lib/widgets/general/breadcrumbs.dart | 10 +++++----- lib/widgets/general/carousel.dart | 2 +- .../general/parabolic_animation_widget.dart | 8 ++++---- .../payment_verification_code_dialog.dart | 2 -- .../general/popup_animation_widget.dart | 10 +++++----- lib/widgets/mobile/create_online_store_1.dart | 2 +- lib/widgets/mobile/mobile_blog.dart | 14 ++++++------- lib/widgets/mobile/mobile_coupons.dart | 8 ++++---- .../mobile/mobile_igoshow_learn_more.dart | 2 +- lib/widgets/mobile/mobile_me.dart | 20 +++++++++---------- lib/widgets/mobile/mobile_my_addresses.dart | 8 ++++---- lib/widgets/mobile/mobile_my_support.dart | 16 +++++++-------- lib/widgets/mobile/mobile_new_address.dart | 2 +- lib/widgets/mobile/mobile_new_comment.dart | 6 +++--- lib/widgets/mobile/mobile_new_ticket.dart | 1 - lib/widgets/mobile/mobile_orders.dart | 16 +++++++-------- lib/widgets/mobile/mobile_product_item.dart | 2 +- lib/widgets/mobile/mobile_search_place.dart | 2 +- lib/widgets/mobile/mobile_view_ticket.dart | 1 - lib/widgets/mobile/product_item.dart | 4 ++-- lib/widgets/mobile/shopping_cart_bar.dart | 6 +++--- 39 files changed, 107 insertions(+), 113 deletions(-) diff --git a/lib/pages/shop.dart b/lib/pages/shop.dart index 4868cdd..f982b6f 100644 --- a/lib/pages/shop.dart +++ b/lib/pages/shop.dart @@ -20,7 +20,7 @@ class ShopState extends State { @override Widget build(BuildContext context) { int _businessId = - widget.businessId == null ? Utils.getBusinessId() : widget.businessId; + widget.businessId == null ? Utils.getBusinessId() : widget.businessId!; return ResponsiveBuilder( builder: (context, sizingInformation) => ScreenTypeLayout( diff --git a/lib/store/actions.dart b/lib/store/actions.dart index 2c04c0f..b4418fd 100644 --- a/lib/store/actions.dart +++ b/lib/store/actions.dart @@ -20,7 +20,7 @@ class UpdateCurrentUser { } class UpdateRedirectRoute { - final String route; + final String? route; UpdateRedirectRoute(this.route); } diff --git a/lib/widgets/desktop/create_online_store_1.dart b/lib/widgets/desktop/create_online_store_1.dart index 6a21476..528f1a1 100644 --- a/lib/widgets/desktop/create_online_store_1.dart +++ b/lib/widgets/desktop/create_online_store_1.dart @@ -40,7 +40,7 @@ class CreateOnlineStore1State extends State { late Group group; - late String selectedDomain; + String? selectedDomain; List domainResult = []; @override diff --git a/lib/widgets/desktop/desktop_blog.dart b/lib/widgets/desktop/desktop_blog.dart index f96cb5d..ea359ac 100644 --- a/lib/widgets/desktop/desktop_blog.dart +++ b/lib/widgets/desktop/desktop_blog.dart @@ -34,7 +34,7 @@ class DesktopBlog extends StatefulWidget { } class DesktopBlogState extends State { - late List blogs; + List? blogs; double division = 2; @@ -49,7 +49,7 @@ class DesktopBlogState extends State { void _onRefresh() { _page = 1; if (blogs != null) { - blogs.clear(); + blogs!.clear(); } else { blogs = []; } @@ -98,7 +98,7 @@ class DesktopBlogState extends State { 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 { 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 { 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) { diff --git a/lib/widgets/desktop/desktop_igoshow_learn_more.dart b/lib/widgets/desktop/desktop_igoshow_learn_more.dart index f3e351a..a3cd22b 100644 --- a/lib/widgets/desktop/desktop_igoshow_learn_more.dart +++ b/lib/widgets/desktop/desktop_igoshow_learn_more.dart @@ -112,7 +112,7 @@ class DesktopiGoShowLearnMoreState extends State { ), child: ClipRRect( borderRadius: BorderRadius.circular(20.0), - child: YoutubePlayerIFrame( + child: YoutubePlayer( controller: _controller, aspectRatio: 1.7778, ), diff --git a/lib/widgets/desktop/desktop_my_addresses.dart b/lib/widgets/desktop/desktop_my_addresses.dart index 9055823..5448ccd 100644 --- a/lib/widgets/desktop/desktop_my_addresses.dart +++ b/lib/widgets/desktop/desktop_my_addresses.dart @@ -30,7 +30,7 @@ class DesktopMyAddresses extends StatefulWidget { } class DesktopMyAddressesState extends State { - late List
addresses; + List
? addresses; double sideSpace = 0; double mainSpace = 1200; @@ -91,9 +91,9 @@ class DesktopMyAddressesState extends State { 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), diff --git a/lib/widgets/desktop/desktop_new_address.dart b/lib/widgets/desktop/desktop_new_address.dart index 1da8c11..4206b1c 100644 --- a/lib/widgets/desktop/desktop_new_address.dart +++ b/lib/widgets/desktop/desktop_new_address.dart @@ -353,7 +353,7 @@ class DesktopNewAddressState extends State { ), bottomNavigationBar: Container( padding: EdgeInsets.all(8.0), - color: Theme.of(context).buttonColor, + color: Theme.of(context).colorScheme.primary, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/lib/widgets/desktop/desktop_new_comment.dart b/lib/widgets/desktop/desktop_new_comment.dart index 4eae9af..ce1bd90 100644 --- a/lib/widgets/desktop/desktop_new_comment.dart +++ b/lib/widgets/desktop/desktop_new_comment.dart @@ -306,7 +306,7 @@ class DesktopNewCommentState extends State { 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 { } }, 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 { 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(), }, diff --git a/lib/widgets/desktop/desktop_new_ticket.dart b/lib/widgets/desktop/desktop_new_ticket.dart index 56a3c66..f7fb766 100644 --- a/lib/widgets/desktop/desktop_new_ticket.dart +++ b/lib/widgets/desktop/desktop_new_ticket.dart @@ -357,7 +357,6 @@ class DesktopNewTicketState extends State { galleryImagesFlag[imageId]['path'] = path; }); }); - return null; } ); }, diff --git a/lib/widgets/desktop/desktop_orders.dart b/lib/widgets/desktop/desktop_orders.dart index 1a89b1e..411b256 100644 --- a/lib/widgets/desktop/desktop_orders.dart +++ b/lib/widgets/desktop/desktop_orders.dart @@ -35,7 +35,7 @@ class DesktopOrders extends StatefulWidget { class DesktopOrdersState extends State with SingleTickerProviderStateMixin { GlobalKey _scaffoldKey = GlobalKey(); - late List orders; + List? orders; bool _isLoading = false; @@ -132,14 +132,14 @@ class DesktopOrdersState extends State 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 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 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 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) { diff --git a/lib/widgets/desktop/desktop_product_item.dart b/lib/widgets/desktop/desktop_product_item.dart index fa6bada..aef9c63 100644 --- a/lib/widgets/desktop/desktop_product_item.dart +++ b/lib/widgets/desktop/desktop_product_item.dart @@ -107,7 +107,7 @@ class DesktopProductItemState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ 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 { crossAxisAlignment: CrossAxisAlignment.start, children: [ 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( diff --git a/lib/widgets/desktop/desktop_search_place.dart b/lib/widgets/desktop/desktop_search_place.dart index b75e4ef..4b4449b 100644 --- a/lib/widgets/desktop/desktop_search_place.dart +++ b/lib/widgets/desktop/desktop_search_place.dart @@ -144,7 +144,7 @@ class DesktopSearchPlaceState extends State { 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,), diff --git a/lib/widgets/desktop/desktop_shopping_cart_widget.dart b/lib/widgets/desktop/desktop_shopping_cart_widget.dart index e8cca7a..7faa8be 100644 --- a/lib/widgets/desktop/desktop_shopping_cart_widget.dart +++ b/lib/widgets/desktop/desktop_shopping_cart_widget.dart @@ -24,7 +24,7 @@ class DesktopShoppingCartWidgetState extends State { @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 { child: row, width: 160.0, ), - onTap: widget.onTap!, + onTap: () => widget.onTap!(), ), ); } diff --git a/lib/widgets/desktop/desktop_view_ticket.dart b/lib/widgets/desktop/desktop_view_ticket.dart index 1b6b3f8..7034f69 100644 --- a/lib/widgets/desktop/desktop_view_ticket.dart +++ b/lib/widgets/desktop/desktop_view_ticket.dart @@ -601,7 +601,6 @@ class DesktopViewTicketState extends State { galleryImagesFlag[imageId]['path'] = path; }); }); - return null; } ); }, diff --git a/lib/widgets/desktop/product_item.dart b/lib/widgets/desktop/product_item.dart index e0f6e1a..fa2b934 100644 --- a/lib/widgets/desktop/product_item.dart +++ b/lib/widgets/desktop/product_item.dart @@ -141,7 +141,7 @@ class ProductItemState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ 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 { crossAxisAlignment: CrossAxisAlignment.start, children: [ 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( diff --git a/lib/widgets/desktop/shop.dart b/lib/widgets/desktop/shop.dart index bd32ac6..eb16352 100644 --- a/lib/widgets/desktop/shop.dart +++ b/lib/widgets/desktop/shop.dart @@ -286,7 +286,7 @@ class ShopState extends State { if (_categoryProducts[i].id == currentCategoryId) { try { CategoryProducts cps = _categoryProducts[i + 1]; - return cps.id; + return cps.id!; } catch (error) { print('Error $error'); } diff --git a/lib/widgets/desktop/shopping_cart_widget.dart b/lib/widgets/desktop/shopping_cart_widget.dart index 49c6b48..d2b67d3 100644 --- a/lib/widgets/desktop/shopping_cart_widget.dart +++ b/lib/widgets/desktop/shopping_cart_widget.dart @@ -25,7 +25,7 @@ class ShoppingCartWidgetState extends State { @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 { child: row, width: 160.0, ), - onTap: widget.onTap!, + onTap: () => widget.onTap!(), ), ); } diff --git a/lib/widgets/general/add_remove_button.dart b/lib/widgets/general/add_remove_button.dart index 85527a8..ee96fec 100644 --- a/lib/widgets/general/add_remove_button.dart +++ b/lib/widgets/general/add_remove_button.dart @@ -61,7 +61,7 @@ class AddRemoveButtonState extends State { Widget build(BuildContext context) { if (widget.product!.leftNum == null) { _qty = 0; - cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business!); + 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 @@ -102,7 +102,7 @@ class AddRemoveButtonState extends State { } if (widget.addToBasket) { _qty = 0; - cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business!); + 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) { @@ -194,7 +194,7 @@ class AddRemoveButtonState extends State { ); } else { _qty = 0; - cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business!); + 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) { diff --git a/lib/widgets/general/breadcrumbs.dart b/lib/widgets/general/breadcrumbs.dart index d6fb6b2..9961f73 100644 --- a/lib/widgets/general/breadcrumbs.dart +++ b/lib/widgets/general/breadcrumbs.dart @@ -94,7 +94,7 @@ class BreadCrumbs extends StatelessWidget { color: Colors.blueAccent, ), Text( - breadCrumb.text, + breadCrumb.text!, style: TextStyle( color: Colors.blueAccent, fontSize: 14.0, @@ -103,7 +103,7 @@ class BreadCrumbs extends StatelessWidget { ], ) : Text( - breadCrumb.text, + breadCrumb.text!, style: TextStyle( color: Colors.blueAccent, fontSize: 14.0, @@ -145,7 +145,7 @@ class BreadCrumbs extends StatelessWidget { color: Colors.lightBlueAccent, ), Text( - breadCrumb.text, + breadCrumb.text!, style: TextStyle( color: Colors.black54, fontSize: 14.0, @@ -155,7 +155,7 @@ class BreadCrumbs extends StatelessWidget { ], ) : Text( - breadCrumb.text, + breadCrumb.text!, style: TextStyle( color: Colors.black54, fontSize: 14.0, @@ -184,7 +184,7 @@ class BreadCrumbs extends StatelessWidget { } class BreadCrumb { - final String text; + final String? text; final String? route; final IconData? icon; final Widget? item; diff --git a/lib/widgets/general/carousel.dart b/lib/widgets/general/carousel.dart index b07f843..9244404 100644 --- a/lib/widgets/general/carousel.dart +++ b/lib/widgets/general/carousel.dart @@ -38,7 +38,7 @@ class CarouselState extends State { @override void initState() { super.initState(); - if (widget.autoPlay) { + if (widget.autoPlay == true) { _timer = new Timer.periodic(widget.duration, (timer) { _pageController.animateToPage(_currentPage, duration: widget.animationDuration, curve: Curves.linear); diff --git a/lib/widgets/general/parabolic_animation_widget.dart b/lib/widgets/general/parabolic_animation_widget.dart index c3dc0bc..8db3dbb 100644 --- a/lib/widgets/general/parabolic_animation_widget.dart +++ b/lib/widgets/general/parabolic_animation_widget.dart @@ -69,13 +69,13 @@ class ParabolicAnimationWidget extends AnimatedWidget { RenderBox stackBox = stackKey.currentContext!.findRenderObject()! as RenderBox; Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero); - EdgeInsets startMargin = _margin(startKey); + EdgeInsets startMargin = _margin(startKey)!; RenderBox startBox = startKey.currentContext!.findRenderObject()! as RenderBox; _startOffset = startBox.localToGlobal(Offset( startMargin.left + startAdjustOffset.dx, stackBoxOffset.dy + startMargin.top + startAdjustOffset.dy)); - EdgeInsets endMargin = _margin(endKey); + EdgeInsets endMargin = _margin(endKey)!; RenderBox endBox = endKey.currentContext!.findRenderObject()! as RenderBox; _endOffset = endBox.localToGlobal(Offset( endMargin.left + endAdjustOffset.dx, @@ -83,9 +83,9 @@ class ParabolicAnimationWidget extends AnimatedWidget { } } - EdgeInsets _margin(GlobalKey key) { + EdgeInsetsGeometry _margin(GlobalKey key) { final Widget widget = key.currentContext!.widget; - EdgeInsets margin = (widget is Container) ? (widget.margin ?? EdgeInsets.zero) : EdgeInsets.zero; + EdgeInsetsGeometry margin = (widget is Container) ? (widget.margin ?? EdgeInsets.zero) : EdgeInsets.zero; return margin ?? EdgeInsets.zero; } } \ No newline at end of file diff --git a/lib/widgets/general/payment_verification_code_dialog.dart b/lib/widgets/general/payment_verification_code_dialog.dart index 4e94a5f..78a51c8 100644 --- a/lib/widgets/general/payment_verification_code_dialog.dart +++ b/lib/widgets/general/payment_verification_code_dialog.dart @@ -109,8 +109,6 @@ class PaymentVerificationCodeDialogState extends State { late Group group; - late String selectedDomain; + String? selectedDomain; List domainResult = []; @override diff --git a/lib/widgets/mobile/mobile_blog.dart b/lib/widgets/mobile/mobile_blog.dart index 20ccafa..50c241a 100644 --- a/lib/widgets/mobile/mobile_blog.dart +++ b/lib/widgets/mobile/mobile_blog.dart @@ -28,7 +28,7 @@ class MobileBlog extends StatefulWidget { } class MobileBlogState extends State { - late List blogs; + List? blogs; int _page = 1; int _pageCount = 1; @@ -41,7 +41,7 @@ class MobileBlogState extends State { void _onRefresh() { _page = 1; if (blogs != null) { - blogs.clear(); + blogs!.clear(); } else { blogs = []; } @@ -82,7 +82,7 @@ class MobileBlogState extends State { 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); @@ -123,9 +123,9 @@ class MobileBlogState extends State { return SizedBox.shrink(); } return ListView.builder( - itemCount: blogs.length <= 1 ? 1 : blogs.length, + itemCount: blogs!.length <= 1 ? 1 : blogs!.length, itemBuilder: (BuildContext context, int i) { - if (blogs.length <= 0) { + if (blogs!.length <= 0) { return Container( padding: EdgeInsets.all(16.0), child: Center( @@ -133,7 +133,7 @@ class MobileBlogState extends State { ), ); } else { - Blog blog = blogs[i]; + Blog blog = blogs![i]; Widget w = Container( padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 16.0), @@ -243,7 +243,7 @@ class MobileBlogState extends State { 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) { diff --git a/lib/widgets/mobile/mobile_coupons.dart b/lib/widgets/mobile/mobile_coupons.dart index 1ba73f7..d41d812 100644 --- a/lib/widgets/mobile/mobile_coupons.dart +++ b/lib/widgets/mobile/mobile_coupons.dart @@ -24,7 +24,7 @@ class MobileCoupons extends StatefulWidget { } class MobileCouponsState extends State { - late List coupons; + List? coupons; @override Widget build(BuildContext context) { @@ -54,10 +54,10 @@ class MobileCouponsState extends State { ), ), body: ListView.builder( - itemCount: coupons.length > 0 ? coupons.length : 1, + itemCount: coupons!.length > 0 ? coupons!.length : 1, itemBuilder: (BuildContext context, int position) { - if (coupons.length > 0) { - Coupon coupon = coupons[position]; + if (coupons!.length > 0) { + Coupon coupon = coupons![position]; return Container( color: Colors.black12, child: couponWidget(coupon), diff --git a/lib/widgets/mobile/mobile_igoshow_learn_more.dart b/lib/widgets/mobile/mobile_igoshow_learn_more.dart index b0c591c..5d256a2 100644 --- a/lib/widgets/mobile/mobile_igoshow_learn_more.dart +++ b/lib/widgets/mobile/mobile_igoshow_learn_more.dart @@ -94,7 +94,7 @@ class MobileiGoShowLearnMoreState extends State { ), child: ClipRRect( borderRadius: BorderRadius.circular(20.0), - child: YoutubePlayerIFrame( + child: YoutubePlayer( controller: _controller, aspectRatio: 2 / 1, ), diff --git a/lib/widgets/mobile/mobile_me.dart b/lib/widgets/mobile/mobile_me.dart index 5cedb06..9757036 100644 --- a/lib/widgets/mobile/mobile_me.dart +++ b/lib/widgets/mobile/mobile_me.dart @@ -40,7 +40,7 @@ class MobileMeState extends State { late String accessToken; late bool isLoading; - late User _user; + User? _user; late ShopScrollCoordinator _shopCoordinator; late ShopScrollController _pageScrollController; @@ -88,9 +88,9 @@ class MobileMeState extends State { children: [ Container( margin: EdgeInsets.only(right: 5.0), - child: _user != null && _user.avatarUrl!.isNotEmpty + child: _user != null && _user!.avatarUrl!.isNotEmpty ? Util.showImage( - 'https:${_user.avatarUrl}', + 'https:${_user!.avatarUrl}', width: 60, height: 60, fit: BoxFit.fill, @@ -116,7 +116,7 @@ class MobileMeState extends State { Container( child: Text( _user != null - ? _user.nickname + ? _user!.nickname! : S.of(context).please_login, style: TextStyle( color: Theme.of(context).scaffoldBackgroundColor, @@ -142,7 +142,7 @@ class MobileMeState extends State { Container( child: Text( _user != null - ? Utils.safePhoneNumber(_user.mobile!) + ? Utils.safePhoneNumber(_user!.mobile!) : '', style: TextStyle( color: @@ -219,7 +219,7 @@ class MobileMeState extends State { Container( child: Text( _user != null - ? '${_user.wallet!.toStringAsFixed(2)}' + ? '${_user!.wallet!.toStringAsFixed(2)}' : '0.00', style: TextStyle( fontSize: 24.0, @@ -262,7 +262,7 @@ class MobileMeState extends State { children: [ Container( child: Text( - _user != null ? '${_user.coupon}' : '0', + _user != null ? '${_user!.coupon}' : '0', style: TextStyle( fontSize: 24.0, color: Colors.orangeAccent, @@ -296,7 +296,7 @@ class MobileMeState extends State { onTap: () { if (_user != null) { Routes.router - .navigateTo(context, '/coupons/${_user.id}'); + .navigateTo(context, '/coupons/${_user!.id}'); } else { _pleaseLoginToast(); } @@ -312,7 +312,7 @@ class MobileMeState extends State { children: [ Container( child: Text( - _user != null ? '${_user.points}' : '0', + _user != null ? '${_user!.points}' : '0', style: TextStyle( fontSize: 24.0, color: Colors.lightGreen, @@ -671,7 +671,7 @@ class MobileMeState extends State { ), onTap: () { if (_user != null) { - if (_user.email == null || _user.email!.isEmpty) { + if (_user!.email == null || _user!.email!.isEmpty) { showDialog( context: context, builder: (BuildContext context) { diff --git a/lib/widgets/mobile/mobile_my_addresses.dart b/lib/widgets/mobile/mobile_my_addresses.dart index 9e0091d..3e27f71 100644 --- a/lib/widgets/mobile/mobile_my_addresses.dart +++ b/lib/widgets/mobile/mobile_my_addresses.dart @@ -27,7 +27,7 @@ class MobileMyAddresses extends StatefulWidget { } class MobileMyAddressesState extends State { - late List
addresses; + List
? addresses; @override Widget build(BuildContext context) { @@ -70,9 +70,9 @@ class MobileMyAddressesState extends State { ], ), body: ListView.builder( - itemCount: addresses.length <= 1 ? 1 : addresses.length, + itemCount: addresses!.length <= 1 ? 1 : addresses!.length, itemBuilder: (BuildContext context, int i) { - if (addresses.length <= 0) { + if (addresses!.length <= 0) { return Container( padding: EdgeInsets.all(16.0), child: Center( @@ -80,7 +80,7 @@ class MobileMyAddressesState extends State { ), ); } else { - Address address = addresses[i]; + Address address = addresses![i]; return Container( padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 16.0), diff --git a/lib/widgets/mobile/mobile_my_support.dart b/lib/widgets/mobile/mobile_my_support.dart index 3962fbf..32d3e54 100644 --- a/lib/widgets/mobile/mobile_my_support.dart +++ b/lib/widgets/mobile/mobile_my_support.dart @@ -28,7 +28,7 @@ class MobileMySupport extends StatefulWidget { } class MobileMySupportState extends State { - late List tickets; + List? tickets; int _page = 1; int _pageCount = 1; @@ -41,7 +41,7 @@ class MobileMySupportState extends State { void _onRefresh() { _page = 1; if (tickets != null) { - tickets.clear(); + tickets!.clear(); } else { tickets = []; } @@ -101,7 +101,7 @@ class MobileMySupportState extends State { 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); @@ -143,9 +143,9 @@ class MobileMySupportState extends State { return SizedBox.shrink(); } return ListView.builder( - itemCount: tickets.length <= 1 ? 1 : tickets.length, + itemCount: tickets!.length <= 1 ? 1 : tickets!.length, itemBuilder: (BuildContext context, int i) { - if (tickets.length <= 0) { + if (tickets!.length <= 0) { return Container( padding: EdgeInsets.all(16.0), child: Center( @@ -153,7 +153,7 @@ class MobileMySupportState extends State { ), ); } else { - Ticket ticket = tickets[i]; + Ticket ticket = tickets![i]; return GestureDetector( onTap: () { @@ -201,7 +201,7 @@ class MobileMySupportState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - ticket.isClosed ? + ticket.isClosed == true ? Container( padding: EdgeInsets.only(right: 10.0), child: Icon(Icons.lock, color: Colors.green, size: 16.0,), @@ -273,7 +273,7 @@ class MobileMySupportState extends State { if (tickets == null) { tickets = []; } - tickets.addAll((value['tickets'] as List).map((e) => Ticket.fromJson(e)).toList()); + tickets!.addAll((value['tickets'] as List).map((e) => Ticket.fromJson(e)).toList()); }); } }).catchError((error) { diff --git a/lib/widgets/mobile/mobile_new_address.dart b/lib/widgets/mobile/mobile_new_address.dart index 1d8dd11..c48dde6 100644 --- a/lib/widgets/mobile/mobile_new_address.dart +++ b/lib/widgets/mobile/mobile_new_address.dart @@ -324,7 +324,7 @@ class MobileNewAddressState extends State { ), bottomNavigationBar: Container( padding: EdgeInsets.all(8.0), - color: Theme.of(context).buttonColor, + color: Theme.of(context).colorScheme.primary, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/lib/widgets/mobile/mobile_new_comment.dart b/lib/widgets/mobile/mobile_new_comment.dart index 9fa08f7..553c407 100644 --- a/lib/widgets/mobile/mobile_new_comment.dart +++ b/lib/widgets/mobile/mobile_new_comment.dart @@ -270,7 +270,7 @@ class MobileNewCommentState extends State { 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); } ); @@ -329,7 +329,7 @@ class MobileNewCommentState extends State { } }, queryParameters: { - 'comment_id': comment != null ? comment.id : 0, + 'comment_id': comment != null ? comment.id! : 0, }, ).catchError((error) { Utils.showMessageDialog(context, error); @@ -356,7 +356,7 @@ class MobileNewCommentState extends State { 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(), }, diff --git a/lib/widgets/mobile/mobile_new_ticket.dart b/lib/widgets/mobile/mobile_new_ticket.dart index 27354f6..1f3fff2 100644 --- a/lib/widgets/mobile/mobile_new_ticket.dart +++ b/lib/widgets/mobile/mobile_new_ticket.dart @@ -331,7 +331,6 @@ class MobileNewTicketState extends State { galleryImagesFlag[imageId]['path'] = path; }); }); - return null; } ); }, diff --git a/lib/widgets/mobile/mobile_orders.dart b/lib/widgets/mobile/mobile_orders.dart index 87ea868..880804b 100644 --- a/lib/widgets/mobile/mobile_orders.dart +++ b/lib/widgets/mobile/mobile_orders.dart @@ -31,7 +31,7 @@ class MobileOrders extends StatefulWidget { class MobileOrdersState extends State with SingleTickerProviderStateMixin { GlobalKey _scaffoldKey = GlobalKey(); - List orders = []; + List? orders; int _page = 1; int _pageCount = 1; @@ -44,7 +44,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta void _onRefresh() { _page = 1; if (orders != null) { - orders.clear(); + orders!.clear(); } else { orders = []; } @@ -79,7 +79,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta 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); @@ -127,11 +127,11 @@ class MobileOrdersState extends State with SingleTickerProviderSta Widget _buildBody() { return ListView.builder( - itemCount: orders != null && orders.length > 0 ? orders.length : 1, + itemCount: orders != null && orders!.length > 0 ? orders!.length : 1, itemBuilder: (BuildContext context, int position) { Order? order; - if (orders != null && orders.length > 0) { - order = orders[position]; + if (orders != null && orders!.length > 0) { + order = orders![position]; } if (order == null) { return Container( @@ -199,7 +199,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta ), ], ); - 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), @@ -438,7 +438,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta if (mounted) { setState(() { _isLoading = false; - 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) { diff --git a/lib/widgets/mobile/mobile_product_item.dart b/lib/widgets/mobile/mobile_product_item.dart index 8f5d695..4fe6aa6 100644 --- a/lib/widgets/mobile/mobile_product_item.dart +++ b/lib/widgets/mobile/mobile_product_item.dart @@ -96,7 +96,7 @@ class MobileProductItemState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ 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( diff --git a/lib/widgets/mobile/mobile_search_place.dart b/lib/widgets/mobile/mobile_search_place.dart index e036ca1..cf03d9f 100644 --- a/lib/widgets/mobile/mobile_search_place.dart +++ b/lib/widgets/mobile/mobile_search_place.dart @@ -123,7 +123,7 @@ class MobileSearchPlaceState extends State { 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,), diff --git a/lib/widgets/mobile/mobile_view_ticket.dart b/lib/widgets/mobile/mobile_view_ticket.dart index dbca2b2..1e5fe8c 100644 --- a/lib/widgets/mobile/mobile_view_ticket.dart +++ b/lib/widgets/mobile/mobile_view_ticket.dart @@ -598,7 +598,6 @@ class MobileViewTicketState extends State { galleryImagesFlag[imageId]['path'] = path; }); }); - return null; } ); }, diff --git a/lib/widgets/mobile/product_item.dart b/lib/widgets/mobile/product_item.dart index 20a17f9..e5f17a6 100644 --- a/lib/widgets/mobile/product_item.dart +++ b/lib/widgets/mobile/product_item.dart @@ -125,7 +125,7 @@ class ProductItemState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ 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( @@ -210,7 +210,7 @@ class ProductItemState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ 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( diff --git a/lib/widgets/mobile/shopping_cart_bar.dart b/lib/widgets/mobile/shopping_cart_bar.dart index 5820bad..5e43e91 100644 --- a/lib/widgets/mobile/shopping_cart_bar.dart +++ b/lib/widgets/mobile/shopping_cart_bar.dart @@ -41,7 +41,7 @@ class ShoppingCartBarState extends State { @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(); } @@ -86,7 +86,7 @@ class ShoppingCartBarState extends State { onTap: () { Utils.clearCart(context, cartInfo, onComplete: (_) { if (widget.onEmptyCartListener != null) { - widget.onEmptyCartListener(); + widget.onEmptyCartListener?.call(); } }); }, @@ -198,7 +198,7 @@ class ShoppingCartBarState extends State { ), onTap: () { if (widget.onPanelOpenCloseRequest != null) { - widget.onPanelOpenCloseRequest(); + widget.onPanelOpenCloseRequest?.call(); } }, ),