From fce670664b3b2260834bf493a32a88f36a3a07ec Mon Sep 17 00:00:00 2001 From: peima Date: Sat, 25 Jul 2026 18:13:01 +0800 Subject: [PATCH] =?UTF-8?q?phase3:=20nullfix.py=20batch=20script=20?= =?UTF-8?q?=E2=80=94=20bang/late/param-nullable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- lib/pages/buy_service.dart | 2 +- lib/pages/contact_us.dart | 2 +- lib/pages/download.dart | 4 +- lib/pages/igoshow_learn_more.dart | 2 +- lib/pages/minipos_learn_more.dart | 2 +- lib/pages/plain_page.dart | 2 +- lib/pages/renew_minioffice.dart | 2 +- lib/utils/double_back_to_close_app.dart | 4 +- lib/utils/http_util.dart | 4 +- lib/utils/util_io.dart | 16 +- .../desktop/create_online_store_1.dart | 8 +- lib/widgets/desktop/desktop_blog.dart | 2 +- lib/widgets/desktop/desktop_buy_service.dart | 2 +- .../desktop_change_mobile_or_email.dart | 26 +-- .../desktop/desktop_change_password.dart | 16 +- lib/widgets/desktop/desktop_checkout.dart | 124 ++++++------- lib/widgets/desktop/desktop_contact_us.dart | 20 +- lib/widgets/desktop/desktop_coupons.dart | 12 +- lib/widgets/desktop/desktop_edit_address.dart | 10 +- .../desktop/desktop_forgot_password.dart | 10 +- lib/widgets/desktop/desktop_login.dart | 8 +- lib/widgets/desktop/desktop_me.dart | 18 +- lib/widgets/desktop/desktop_my_addresses.dart | 2 +- lib/widgets/desktop/desktop_my_support.dart | 6 +- lib/widgets/desktop/desktop_new_address.dart | 20 +- lib/widgets/desktop/desktop_new_comment.dart | 14 +- lib/widgets/desktop/desktop_new_ticket.dart | 2 +- lib/widgets/desktop/desktop_new_user.dart | 10 +- lib/widgets/desktop/desktop_order_detail.dart | 68 +++---- lib/widgets/desktop/desktop_orders.dart | 12 +- lib/widgets/desktop/desktop_pay_now.dart | 10 +- .../desktop/desktop_product_detail_page.dart | 26 +-- lib/widgets/desktop/desktop_product_item.dart | 4 +- .../desktop/desktop_renew_license.dart | 2 +- .../desktop/desktop_reset_password.dart | 12 +- lib/widgets/desktop/desktop_search_place.dart | 2 +- lib/widgets/desktop/desktop_set_password.dart | 12 +- .../desktop/desktop_shopping_cart_widget.dart | 4 +- .../desktop/desktop_store_product_search.dart | 2 +- lib/widgets/desktop/desktop_user_profile.dart | 12 +- lib/widgets/desktop/desktop_view_blog.dart | 2 +- lib/widgets/desktop/desktop_view_ticket.dart | 18 +- lib/widgets/desktop/product_item.dart | 8 +- lib/widgets/desktop/product_search.dart | 2 +- lib/widgets/desktop/shop.dart | 8 +- lib/widgets/desktop/shop_bulletin.dart | 2 +- lib/widgets/desktop/shop_products.dart | 26 +-- lib/widgets/desktop/shop_promote.dart | 16 +- lib/widgets/desktop/shopping_cart_widget.dart | 4 +- lib/widgets/general/add_remove_button.dart | 50 ++--- .../general/animation_point_manager.dart | 8 +- .../general/attribute/check_options.dart | 70 +++---- .../general/attribute/options_base.dart | 6 +- .../general/attribute/qty_options.dart | 94 +++++----- .../general/attribute/radio_options.dart | 40 ++-- lib/widgets/general/carousel.dart | 10 +- lib/widgets/general/e_transfer_pay.dart | 2 +- .../general/parabolic_animation_widget.dart | 10 +- .../payment_verification_code_dialog.dart | 4 +- .../general/popup_animation_widget.dart | 8 +- lib/widgets/general/sliding_up_panel.dart | 16 +- lib/widgets/mobile/create_online_store_1.dart | 8 +- .../mobile/mobile_attribute_selection.dart | 44 ++--- lib/widgets/mobile/mobile_blog.dart | 2 +- lib/widgets/mobile/mobile_buy_service.dart | 2 +- .../mobile/mobile_change_mobile_or_email.dart | 26 +-- .../mobile/mobile_change_password.dart | 16 +- lib/widgets/mobile/mobile_checkout.dart | 146 +++++++-------- lib/widgets/mobile/mobile_contact_us.dart | 20 +- lib/widgets/mobile/mobile_coupons.dart | 12 +- lib/widgets/mobile/mobile_edit_address.dart | 10 +- .../mobile/mobile_forgot_password.dart | 10 +- lib/widgets/mobile/mobile_login.dart | 8 +- lib/widgets/mobile/mobile_me.dart | 26 +-- lib/widgets/mobile/mobile_my_addresses.dart | 2 +- lib/widgets/mobile/mobile_my_support.dart | 6 +- lib/widgets/mobile/mobile_new_address.dart | 20 +- lib/widgets/mobile/mobile_new_comment.dart | 14 +- lib/widgets/mobile/mobile_new_ticket.dart | 2 +- lib/widgets/mobile/mobile_new_user.dart | 10 +- lib/widgets/mobile/mobile_order_detail.dart | 70 +++---- lib/widgets/mobile/mobile_orders.dart | 10 +- lib/widgets/mobile/mobile_pay_now.dart | 10 +- .../mobile/mobile_product_detail_page.dart | 40 ++-- lib/widgets/mobile/mobile_product_item.dart | 2 +- lib/widgets/mobile/mobile_renew_license.dart | 2 +- .../mobile/mobile_renew_minioffice.dart | 2 +- lib/widgets/mobile/mobile_reset_password.dart | 12 +- lib/widgets/mobile/mobile_search_place.dart | 2 +- lib/widgets/mobile/mobile_set_password.dart | 12 +- .../mobile/mobile_store_product_search.dart | 2 +- lib/widgets/mobile/mobile_user_profile.dart | 12 +- lib/widgets/mobile/mobile_view_blog.dart | 2 +- lib/widgets/mobile/mobile_view_ticket.dart | 20 +- lib/widgets/mobile/product_item.dart | 8 +- lib/widgets/mobile/product_search.dart | 2 +- lib/widgets/mobile/shop.dart | 140 +++++++------- lib/widgets/mobile/shopping_cart_bar.dart | 24 +-- tools/nullfix.py | 175 ++++++++++++++++++ 99 files changed, 1013 insertions(+), 838 deletions(-) create mode 100644 tools/nullfix.py diff --git a/lib/pages/buy_service.dart b/lib/pages/buy_service.dart index 7d946f9..733f1b6 100644 --- a/lib/pages/buy_service.dart +++ b/lib/pages/buy_service.dart @@ -30,7 +30,7 @@ class BuyService extends StatefulWidget { } class BuyServiceState extends State { - Map data; + late Map data; @override Widget build(BuildContext context) { diff --git a/lib/pages/contact_us.dart b/lib/pages/contact_us.dart index 732e460..3c4a61e 100644 --- a/lib/pages/contact_us.dart +++ b/lib/pages/contact_us.dart @@ -22,7 +22,7 @@ class ContactUs extends StatefulWidget { } class ContactUsState extends State { - Business business; + late Business business; @override Widget build(BuildContext context) { diff --git a/lib/pages/download.dart b/lib/pages/download.dart index e72f259..5117a73 100644 --- a/lib/pages/download.dart +++ b/lib/pages/download.dart @@ -30,7 +30,7 @@ class Download extends StatefulWidget { class DownloadState extends State { final _scaffoldKey = GlobalKey(); - Map data; + late Map data; @override Widget build(BuildContext context) { @@ -79,7 +79,7 @@ class DownloadState extends State { super.initState(); eventBus.on().listen((event) { if (mounted) { - _scaffoldKey.currentState.openDrawer(); + _scaffoldKey.currentState!.openDrawer(); } }); _loadData(); diff --git a/lib/pages/igoshow_learn_more.dart b/lib/pages/igoshow_learn_more.dart index c131b54..e283add 100644 --- a/lib/pages/igoshow_learn_more.dart +++ b/lib/pages/igoshow_learn_more.dart @@ -26,7 +26,7 @@ class IGoShowLearnMore extends StatefulWidget { class IGoShowLearnMoreState extends State { final _scaffoldKey = GlobalKey(); - Map data; + late Map data; @override Widget build(BuildContext context) { diff --git a/lib/pages/minipos_learn_more.dart b/lib/pages/minipos_learn_more.dart index 4c13c5f..9ca8a01 100644 --- a/lib/pages/minipos_learn_more.dart +++ b/lib/pages/minipos_learn_more.dart @@ -26,7 +26,7 @@ class MiniPosLearnMore extends StatefulWidget { class MiniPosLearnMoreState extends State { final _scaffoldKey = GlobalKey(); - Map data; + late Map data; @override Widget build(BuildContext context) { diff --git a/lib/pages/plain_page.dart b/lib/pages/plain_page.dart index 369d879..ccfbc72 100644 --- a/lib/pages/plain_page.dart +++ b/lib/pages/plain_page.dart @@ -23,7 +23,7 @@ class PlainPage extends StatefulWidget { } class PlainPageState extends State { - Blog blog; + late Blog blog; @override Widget build(BuildContext context) { diff --git a/lib/pages/renew_minioffice.dart b/lib/pages/renew_minioffice.dart index 1a0e3de..93ee0b2 100644 --- a/lib/pages/renew_minioffice.dart +++ b/lib/pages/renew_minioffice.dart @@ -25,7 +25,7 @@ class RenewMiniOffice extends StatefulWidget { } class RenewMiniOfficeState extends State { - Map data; + late Map data; @override Widget build(BuildContext context) { diff --git a/lib/utils/double_back_to_close_app.dart b/lib/utils/double_back_to_close_app.dart index 16826f3..a786d63 100644 --- a/lib/utils/double_back_to_close_app.dart +++ b/lib/utils/double_back_to_close_app.dart @@ -34,7 +34,7 @@ class DoubleBackToCloseApp extends StatefulWidget { class _DoubleBackToCloseAppState extends State { /// The last time the user tapped Android's back-button. - DateTime _lastTimeBackButtonWasTapped; + late DateTime _lastTimeBackButtonWasTapped; /// Returns whether the current platform is Android. bool get _isAndroid => Theme.of(context).platform == TargetPlatform.android; @@ -59,7 +59,7 @@ class _DoubleBackToCloseAppState extends State { /// local-history of the current route, in order to handle pop. This is done /// by [Drawer], for example, so it can close on pop. bool get _willHandlePopInternally => - ModalRoute.of(context).willHandlePopInternally; + ModalRoute.of(context)!.willHandlePopInternally; @override Widget build(BuildContext context) { diff --git a/lib/utils/http_util.dart b/lib/utils/http_util.dart index 7c12e0e..ffa051e 100644 --- a/lib/utils/http_util.dart +++ b/lib/utils/http_util.dart @@ -35,8 +35,8 @@ class HttpUtil { 'Http-Contact-Authorization': '', 'Http-Device-Type': Utils.getOs(checkWeb: true), 'Http-Api-Branch': 'flutter', - 'Http-Language-Code': store.state.locale.languageCode, - 'Http-Country-Code': store.state.locale.countryCode ?? '', + 'Http-Language-Code': store.state.locale!.languageCode, + 'Http-Country-Code': store.state.locale!.countryCode ?? '', }; static Future httpGet(String url, diff --git a/lib/utils/util_io.dart b/lib/utils/util_io.dart index dd74031..907241a 100644 --- a/lib/utils/util_io.dart +++ b/lib/utils/util_io.dart @@ -199,8 +199,8 @@ class Util { return box; } - static Widget showImage(String imageUrl, {double width, double height, - BoxFit fit, Widget Function(BuildContext, String, dynamic) errorWidget}) { + static Widget showImage(String imageUrl, {double? width, double? height, + BoxFit? fit, Widget Function(BuildContext, String, dynamic)? errorWidget}) { if (imageUrl != null && imageUrl.isNotEmpty && imageUrl.startsWith('https:')) { return CachedNetworkImage( imageUrl: imageUrl, @@ -317,14 +317,14 @@ class Util { final picker = ImagePicker(); var image = await picker.pickImage(source: ImageSource.gallery); Navigator.of(context).pop(); - uploadPicture(context, File(image.path), user, commentId: commentId, orderId: orderId); + uploadPicture(context, File(image!.path), user, commentId: commentId, orderId: orderId); } void getPictureFromCamera(BuildContext context, User user, {int commentId = -1, int orderId = 0}) async { final picker = ImagePicker(); var image = await picker.pickImage(source: ImageSource.camera); Navigator.of(context).pop(); - uploadPicture(context, File(image.path), user, commentId: commentId, orderId: orderId); + uploadPicture(context, File(image!.path), user, commentId: commentId, orderId: orderId); } void uploadPicture(BuildContext context, File image, User user, {int commentId = -1, int orderId = 0}) async { @@ -454,18 +454,18 @@ class Util { ImagePicker picker = ImagePicker(); var image = await picker.pickImage(source: ImageSource.gallery); Navigator.of(context).pop(); - onGotFile(imageId, image.path); + onGotFile(imageId, image!.path); } void getPictureFromCamera2(BuildContext context, int imageId, OnGotFile onGotFile) async { ImagePicker picker = ImagePicker(); var image = await picker.pickImage(source: ImageSource.camera); Navigator.of(context).pop(); - onGotFile(imageId, image.path); + onGotFile(imageId, image!.path); } Future createTicket(BuildContext context, String msg, List> images, - OnSuccess onSuccess, OnError onError, {int id}) { + OnSuccess onSuccess, OnError onError, {int? id}) { var formData = FormData(); formData.fields.add(MapEntry("msg", msg)); formData.fields.add(MapEntry('id', id == null ? '0' : id.toString())); @@ -555,6 +555,6 @@ class Util { ByteData data = await rootBundle.load(path); ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(), targetWidth: width); ui.FrameInfo fi = await codec.getNextFrame(); - return (await fi.image.toByteData(format: ui.ImageByteFormat.png)).buffer.asUint8List(); + return (await fi.image.toByteData(format: ui.ImageByteFormat.png))!.buffer.asUint8List(); } } \ No newline at end of file diff --git a/lib/widgets/desktop/create_online_store_1.dart b/lib/widgets/desktop/create_online_store_1.dart index 587825f..f232db7 100644 --- a/lib/widgets/desktop/create_online_store_1.dart +++ b/lib/widgets/desktop/create_online_store_1.dart @@ -35,12 +35,12 @@ class CreateOnlineStore1State extends State { bool canSubmit = false; List stores = []; - Map service; + late Map service; dynamic selectedStore; - Group group; + late Group group; - String selectedDomain; + late String selectedDomain; List domainResult = []; @override @@ -284,7 +284,7 @@ class CreateOnlineStore1State extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).domains_separated_comma; } return null; diff --git a/lib/widgets/desktop/desktop_blog.dart b/lib/widgets/desktop/desktop_blog.dart index 09047fe..8064303 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 { - List blogs; + late List blogs; double division = 2; diff --git a/lib/widgets/desktop/desktop_buy_service.dart b/lib/widgets/desktop/desktop_buy_service.dart index 07508a2..a3eae26 100644 --- a/lib/widgets/desktop/desktop_buy_service.dart +++ b/lib/widgets/desktop/desktop_buy_service.dart @@ -27,7 +27,7 @@ class DesktopBuyServiceState extends State { double mainSpace = 1200; List plans = []; - KeyValue selectedPlan; + late KeyValue selectedPlan; double price = 0.0; double tax = 0.0; double paymentAmount = 0.0; diff --git a/lib/widgets/desktop/desktop_change_mobile_or_email.dart b/lib/widgets/desktop/desktop_change_mobile_or_email.dart index 9e7717c..4d31a5c 100644 --- a/lib/widgets/desktop/desktop_change_mobile_or_email.dart +++ b/lib/widgets/desktop/desktop_change_mobile_or_email.dart @@ -32,9 +32,9 @@ class DesktopChangeMobileOrEmailState extends State bool usernameEnable = true; final codeController = TextEditingController(); - bool enableGetCode; - String getCodeText; - bool canRegister; + late bool enableGetCode; + late String getCodeText; + late bool canRegister; var countDownListener; @@ -88,7 +88,7 @@ class DesktopChangeMobileOrEmailState extends State ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { if (widget.isMobile) { return S .of(context) @@ -99,10 +99,10 @@ class DesktopChangeMobileOrEmailState extends State .email_is_required; } } - if (widget.isMobile && value.trim() == store.state.user.mobile) { + if (widget.isMobile && value!.trim() == store.state.user!.mobile) { return S.of(context).the_mobile_number_is_same_as_current; } - if (!widget.isMobile && value.trim() == store.state.user.email) { + if (!widget.isMobile && value!.trim() == store.state.user!.email) { return S.of(context).the_email_is_same_as_current; } return null; @@ -185,7 +185,7 @@ class DesktopChangeMobileOrEmailState extends State fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).verification_code_is_required; } return null; @@ -332,7 +332,7 @@ class DesktopChangeMobileOrEmailState extends State }, isFormData: true, body: { - 'id': store.state.user.id, + 'id': store.state.user!.id, 'mobile': usernameController.text.trim(), 'code': codeController.text.trim(), }, @@ -344,8 +344,8 @@ class DesktopChangeMobileOrEmailState extends State void getCodeTapped() { if (usernameController.text.isNotEmpty && - ((widget.isMobile && usernameController.text.trim() != store.state.user.mobile) || - (!widget.isMobile && usernameController.text.trim() != store.state.user.email))) { + ((widget.isMobile && usernameController.text.trim() != store.state.user!.mobile) || + (!widget.isMobile && usernameController.text.trim() != store.state.user!.email))) { HttpUtil.httpPost('v1/users', (response) { Fluttertoast.showToast( msg: S.of(context).verification_code_sent, @@ -366,7 +366,7 @@ class DesktopChangeMobileOrEmailState extends State 'action': 'change_mobile_email_send_code' }, body: { - 'id': store.state.user.id, + 'id': store.state.user!.id, 'mobile': usernameController.text, }, isFormData: true, @@ -384,9 +384,9 @@ class DesktopChangeMobileOrEmailState extends State errorMsg = S.of(context).mobile_is_required; } else if (!widget.isMobile && usernameController.text.trim().isEmpty) { errorMsg = S.of(context).email_is_required; - } else if (widget.isMobile && usernameController.text.trim() == store.state.user.mobile) { + } else if (widget.isMobile && usernameController.text.trim() == store.state.user!.mobile) { errorMsg = S.of(context).the_mobile_number_is_same_as_current; - } else if (!widget.isMobile && usernameController.text.trim() == store.state.user.email) { + } else if (!widget.isMobile && usernameController.text.trim() == store.state.user!.email) { errorMsg = S.of(context).the_email_is_same_as_current; } Fluttertoast.showToast( diff --git a/lib/widgets/desktop/desktop_change_password.dart b/lib/widgets/desktop/desktop_change_password.dart index 75f2488..197821e 100644 --- a/lib/widgets/desktop/desktop_change_password.dart +++ b/lib/widgets/desktop/desktop_change_password.dart @@ -24,10 +24,10 @@ class DesktopChangePasswordState extends State { final passwordController = TextEditingController(); final passwordAgainController = TextEditingController(); - bool passwordVisible; - bool passwordAgainVisible; + late bool passwordVisible; + late bool passwordAgainVisible; - bool canReset; + late bool canReset; double sideSpace = 0; double mainSpace = 1200; @@ -138,7 +138,7 @@ class DesktopChangePasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).current_password_is_required; } return null; @@ -192,7 +192,7 @@ class DesktopChangePasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } return null; @@ -246,10 +246,10 @@ class DesktopChangePasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } - if (value.trim() != passwordController.text.trim()) { + if (value!.trim() != passwordController.text.trim()) { return S.of(context).password_is_not_match_password_again; } return null; @@ -338,7 +338,7 @@ class DesktopChangePasswordState extends State { }, isFormData: true, body: { - 'id': store.state.user.id, + 'id': store.state.user!.id, 'old_password': oldPasswordController.text.trim(), 'password': passwordController.text.trim(), } diff --git a/lib/widgets/desktop/desktop_checkout.dart b/lib/widgets/desktop/desktop_checkout.dart index cd57462..c6654c3 100644 --- a/lib/widgets/desktop/desktop_checkout.dart +++ b/lib/widgets/desktop/desktop_checkout.dart @@ -222,7 +222,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - '\$${(cartInfo.totalPrice - couponDiscountAmount).toStringAsFixed(2)}', + '\$${(cartInfo.totalPrice! - couponDiscountAmount).toStringAsFixed(2)}', style: TextStyle( fontSize: 20.0, color: Colors.white, @@ -292,7 +292,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi itemCount: 6, addAutomaticKeepAlives: true, itemBuilder: (BuildContext context, int position) { - var deliveryTimeInSeconds = cartInfo.businessInfo.shippingTime * 60 + (durationInTraffic != null ? durationInTraffic.value : 0); + var deliveryTimeInSeconds = cartInfo!.businessInfo!.shippingTime! * 60 + (durationInTraffic != null ? durationInTraffic!.value : 0); print('aaa: $deliveryTimeInSeconds'); DateTime now = DateTime.now(); var formatter = DateFormat('H:mm'); @@ -366,7 +366,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi ); switch (position) { case 0: - if (cartInfo.businessInfo.deliveryPickup) { + if (cartInfo!.businessInfo!.deliveryPickup) { return Container( padding: EdgeInsets.only( top: 16.0, bottom: 16.0, left: 16.0, right: 16.0), @@ -380,8 +380,8 @@ class DesktopCheckoutState extends State with SingleTickerProvi ), child: Container( alignment: Alignment.centerLeft, - child: store.state.deviceId != null && store.state.deviceId.isNotEmpty ? ( - store.state.tableNumber != null && store.state.tableNumber.isNotEmpty ? + child: store.state.deviceId != null && store.state.deviceId!.isNotEmpty ? ( + store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty ? peopleCountSelection : SizedBox.shrink() ) : Center(child: toggleSwitch,), @@ -394,8 +394,8 @@ class DesktopCheckoutState extends State with SingleTickerProvi } break; case 1: - if (store.state.deviceId != null && store.state.deviceId.isNotEmpty || - store.state.tableNumber != null && store.state.tableNumber.isNotEmpty) { + if (store.state.deviceId != null && store.state.deviceId!.isNotEmpty || + store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty) { return SizedBox.shrink(); } if (deliveryMethod == 'pickup') { @@ -414,7 +414,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi Container( margin: EdgeInsets.only(top: 10.0), child: Text( - cartInfo.businessInfo.name, + cartInfo!.businessInfo!.name, style: TextStyle( fontSize: 17.0, ), @@ -423,7 +423,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi Container( margin: EdgeInsets.only(top: 5.0), child: Text( - cartInfo.businessInfo.address.addressLine1, + cartInfo!.businessInfo!.address!.addressLine1, style: TextStyle( fontSize: 14.0, color: Colors.black45, @@ -431,9 +431,9 @@ class DesktopCheckoutState extends State with SingleTickerProvi ), ), Container( - child: cartInfo.businessInfo.address.addressLine2 != null - && cartInfo.businessInfo.address.addressLine2.length > 0 ? - Text(cartInfo.businessInfo.address.addressLine2, + child: cartInfo!.businessInfo!.address!.addressLine2 != null + && cartInfo!.businessInfo!.address!.addressLine2!.length > 0 ? + Text(cartInfo!.businessInfo!.address!.addressLine2, style: TextStyle( fontSize: 14.0, color: Colors.black45, @@ -442,7 +442,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi ), Container( child: Text( - '${cartInfo.businessInfo.address.city}, ${cartInfo.businessInfo.address.state}, ${cartInfo.businessInfo.address.zip}', + '${cartInfo!.businessInfo!.address!.city}, ${cartInfo!.businessInfo!.address!.state}, ${cartInfo!.businessInfo!.address!.zip}', style: TextStyle( fontSize: 14.0, color: Colors.black45, @@ -452,7 +452,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi Container( margin: EdgeInsets.only(top: 5.0), child: Text( - 'Tel: ${cartInfo.businessInfo.phone}', + 'Tel: ${cartInfo!.businessInfo!.phone}', style: TextStyle( fontSize: 15.0, color: Colors.black54, @@ -494,7 +494,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi children: [ Container( child: Text( - shipAddress != null ? shipAddress.fullAddress : S.of(context).enter_delivery_address, + shipAddress != null ? shipAddress!.fullAddress : S.of(context).enter_delivery_address, style: TextStyle( fontSize: 16.0 ), @@ -505,7 +505,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi Container( padding: EdgeInsets.only(top: 6.0), child: Text( - shipAddress != null ? shipAddress.contactName + ' ' + shipAddress.phone : '', + shipAddress != null ? shipAddress!.contactName! + ' ' + shipAddress!.phone : '', style: TextStyle( fontSize: 14.0, color: Colors.black38, @@ -529,13 +529,13 @@ class DesktopCheckoutState extends State with SingleTickerProvi ), ), onTap: () { - Routes.router.navigateTo(context, '/my-addresses/${cartInfo.businessInfo.id}', replace: true); + Routes.router.navigateTo(context, '/my-addresses/${cartInfo!.businessInfo!.id}', replace: true); }, ); break; case 2: - if (deliveryMethod == 'pickup' || store.state.deviceId != null && store.state.deviceId.isNotEmpty || - store.state.tableNumber != null && store.state.tableNumber.isNotEmpty) { + if (deliveryMethod == 'pickup' || store.state.deviceId != null && store.state.deviceId!.isNotEmpty || + store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty) { return SizedBox.shrink(); } if (deliveryMethod == 'canada-post') { @@ -578,7 +578,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi alignment: Alignment.centerRight, child: Text( selectedShippingRate != null ? - '${selectedShippingRate.name} \$${selectedShippingRate.price.toStringAsFixed(2)}' : + '${selectedShippingRate!.name} \$${selectedShippingRate!.price!.toStringAsFixed(2)}' : S.of(context).please_select, style: TextStyle( fontSize: 15.0, @@ -608,7 +608,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi }, ); } - if (!cartInfo.businessInfo.instanceDelivery) { + if (!cartInfo!.businessInfo!.instanceDelivery) { return Container( padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 0.0, bottom: 16.0), child: Text(S.of(context).no_instance_delivery_desc), @@ -654,7 +654,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi child: Text( bookingTimeList.length > 0 ? '${Utils.timestampToString(context, bookingTimeList[bookingTimeIndex].unixTime)}' : ((bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ? '' - : bookingDateTimeList[bookingDateIndex].viewDate + ' ' + (bookingDateTimeList[bookingDateIndex].bookTimes.length > 0 ? bookingDateTimeList[bookingDateIndex].bookTimes[bookingTimeIndex].viewTime : '')), + : bookingDateTimeList[bookingDateIndex].viewDate! + ' ' + (bookingDateTimeList[bookingDateIndex].bookTimes!.length > 0 ? bookingDateTimeList[bookingDateIndex].bookTimes![bookingTimeIndex].viewTime : '')), ), ), Container( @@ -737,7 +737,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi width: double.infinity, padding: EdgeInsets.only(bottom: 10.0), child: Text( - cartInfo.businessInfo.name, + cartInfo!.businessInfo!.name, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 16.0, @@ -756,9 +756,9 @@ class DesktopCheckoutState extends State with SingleTickerProvi subtotal = 0.0; - for (var i = 0; i < cartInfo.productList.length; i++) { - subtotal += cartInfo.productList[i].totalPrice; - column.children.add(lineItem(cartInfo.productList[i])); + for (var i = 0; i < cartInfo!.productList!.length; i++) { + subtotal += cartInfo!.productList![i].totalPrice; + column.children.add(lineItem(cartInfo!.productList![i])); } column.children.add(GestureDetector( child: Container( @@ -851,8 +851,8 @@ class DesktopCheckoutState extends State with SingleTickerProvi ), )); - if (cartInfo.extraFeeList.length > 0) { - for (var i = 0; i < cartInfo.extraFeeList.length; i++) { + if (cartInfo!.extraFeeList!.length > 0) { + for (var i = 0; i < cartInfo!.extraFeeList!.length; i++) { column.children.add(Container( padding: EdgeInsets.only(bottom: 16.0), alignment: Alignment.centerRight, @@ -863,7 +863,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi Container( alignment: Alignment.centerRight, child: Text( - S.of(context).extra_fee_token(cartInfo.extraFeeList[i].name, cartInfo.extraFeeList[i].rate), + S.of(context).extra_fee_token(cartInfo!.extraFeeList![i].name, cartInfo!.extraFeeList![i].rate), style: TextStyle( color: Colors.grey, ), @@ -873,7 +873,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi width: 100.0, alignment: Alignment.centerRight, child: Text( - '${cartInfo.extraFeeList[i].price.toStringAsFixed(2)}' + '${cartInfo!.extraFeeList![i].price!.toStringAsFixed(2)}' ), ), ], @@ -901,7 +901,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi width: 100.0, alignment: Alignment.centerRight, child: Text( - '${(cartInfo.totalPrice - couponDiscountAmount).toStringAsFixed(2)}', + '${(cartInfo!.totalPrice! - couponDiscountAmount).toStringAsFixed(2)}', style: TextStyle( fontSize: 19.0, fontWeight: FontWeight.bold, @@ -999,7 +999,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi children: [ Container( padding: EdgeInsets.all(5.0), - child: Util.showImage('${cartLineItem.product.imagePath}', + child: Util.showImage('${cartLineItem.product!.imagePath}', width: 80.0, height: 80.0, fit: BoxFit.fill, @@ -1036,14 +1036,14 @@ class DesktopCheckoutState extends State with SingleTickerProvi alignment: Alignment.centerRight, margin: EdgeInsets.only(right: 10.0), child: Text( - 'x${cartLineItem.quantity.round()}', + 'x${cartLineItem.quantity!.round()}', ), ), Container( width: 60.0, alignment: Alignment.centerRight, child: Text( - '${cartLineItem.totalPrice.toStringAsFixed(2)}', + '${cartLineItem.totalPrice!.toStringAsFixed(2)}', ), ), ], @@ -1099,7 +1099,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi shippingRates = (response.data['shipping_rates'] as List).map((e) => ShippingRate.fromJson(e)).toList(); selectedShippingRate = (response.data['selected_shipping_rate'] as String).length > 0 ? ShippingRate.fromJson(json.decode(response.data['selected_shipping_rate'])) : null; int i = 0; - if (cartInfo.businessInfo.deliveryStoreDelivery) { + if (cartInfo!.businessInfo!.deliveryStoreDelivery) { shippingMethodLabels.add(S.of(context).delivery); shippingMethodIcons.add(Icons.directions_car); if (deliveryMethod == 'store-delivery') { @@ -1107,7 +1107,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi } i++; } - if (cartInfo.businessInfo.deliveryCanadaPost) { + if (cartInfo!.businessInfo!.deliveryCanadaPost) { shippingMethodLabels.add(S.of(context).canada_post); shippingMethodIcons.add(Icons.local_shipping); if (deliveryMethod == 'canada-post') { @@ -1115,7 +1115,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi } i++; } - if (cartInfo.businessInfo.deliveryPickup) { + if (cartInfo!.businessInfo!.deliveryPickup) { shippingMethodLabels.add(S.of(context).pickup); shippingMethodIcons.add(Icons.store); if (deliveryMethod == 'pickup') { @@ -1335,14 +1335,14 @@ class DesktopCheckoutState extends State with SingleTickerProvi Expanded( child: SizedBox.expand( child: ListView.builder( - itemCount: bookingDateTimeList[bookingDateIndex].bookTimes.length, + itemCount: bookingDateTimeList[bookingDateIndex].bookTimes!.length, itemBuilder: (BuildContext context, int position) { BookingDateTime bookingDateTime = bookingDateTimeList[bookingDateIndex]; return GestureDetector( child: Container( padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0, bottom: 12.0), child: Text( - bookingDateTime.bookTimes[position].viewTime, + bookingDateTime.bookTimes![position].viewTime, ), decoration: BoxDecoration( border: Border( @@ -1467,16 +1467,16 @@ class DesktopCheckoutState extends State with SingleTickerProvi itemBuilder: (BuildContext context, int position) { PaymentPlatform paymentPlatform = paymentPlatforms[position]; if (paymentPlatform.code == Constants.PAYMENT_METHOD_CODE_SQUARE && - (paymentPlatform.squareAppId == null || paymentPlatform.squareAppId.isEmpty) && - (paymentPlatform.squareAccessToken == null || paymentPlatform.squareAccessToken.isEmpty) && - (paymentPlatform.squareLocationId == null || paymentPlatform.squareLocationId.isEmpty) + (paymentPlatform.squareAppId == null || paymentPlatform.squareAppId!.isEmpty) && + (paymentPlatform.squareAccessToken == null || paymentPlatform.squareAccessToken!.isEmpty) && + (paymentPlatform.squareLocationId == null || paymentPlatform.squareLocationId!.isEmpty) ) { return SizedBox.shrink(); } if (paymentPlatform.code == Constants.PAYMENT_METHOD_CODE_CHASE && - (paymentPlatform.xLogin == null || paymentPlatform.xLogin.isEmpty) && - (paymentPlatform.transactionKey == null || paymentPlatform.transactionKey.isEmpty) && - (paymentPlatform.responseKey == null || paymentPlatform.responseKey.isEmpty) + (paymentPlatform.xLogin == null || paymentPlatform.xLogin!.isEmpty) && + (paymentPlatform.transactionKey == null || paymentPlatform.transactionKey!.isEmpty) && + (paymentPlatform.responseKey == null || paymentPlatform.responseKey!.isEmpty) ) { return SizedBox.shrink(); } @@ -1566,7 +1566,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi String getSelectedCouponName() { if (selectedCoupon == null) { - if (coupons.length > 0) { + if (coupons!.length > 0) { return S .of(context) .please_select; @@ -1578,10 +1578,10 @@ class DesktopCheckoutState extends State with SingleTickerProvi } else if (selectedCoupon == 0) { return S.of(context).dont_use; } else { - for (var i = 0; i < coupons.length; i++) { - if (selectedCoupon == coupons[i].id) { - if (coupons[i].isPercentage) { - return S.of(context).percentage_discount_token2(couponDiscountAmount.toStringAsFixed(2), coupons[i].valueAmount); + for (var i = 0; i < coupons!.length; i++) { + if (selectedCoupon == coupons![i].id) { + if (coupons![i].isPercentage) { + return S.of(context).percentage_discount_token2(couponDiscountAmount.toStringAsFixed(2), coupons![i].valueAmount); } else { return S.of(context).discount_amount_token(couponDiscountAmount.toStringAsFixed(2)); } @@ -1700,13 +1700,13 @@ class DesktopCheckoutState extends State with SingleTickerProvi } else { widget.children.add(Expanded( child: ListView.builder( - itemCount: coupons.length + 1, + itemCount: coupons!.length + 1, itemBuilder: (BuildContext context, int position) { if (position == 0) { return GestureDetector( child: Container( decoration: selectedCoupon == 0 ? BoxDecoration( - color: subtotal > cartInfo.businessInfo.minPrice ? Colors + color: subtotal > cartInfo!.businessInfo!.minPrice ? Colors .transparent : Colors.black38, border: Border( top: BorderSide( @@ -1727,7 +1727,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi ), ), ) : BoxDecoration( - color: subtotal > cartInfo.businessInfo.minPrice ? Colors + color: subtotal > cartInfo!.businessInfo!.minPrice ? Colors .transparent : Colors.black38, ), child: Row( @@ -1764,11 +1764,11 @@ class DesktopCheckoutState extends State with SingleTickerProvi }, ); } else { - Coupon coupon = coupons[position - 1]; + Coupon coupon = coupons![position - 1]; return GestureDetector( child: Container( decoration: selectedCoupon == coupon.id ? BoxDecoration( - color: subtotal > cartInfo.businessInfo.minPrice ? Colors + color: subtotal > cartInfo!.businessInfo!.minPrice ? Colors .transparent : Colors.black38, border: Border( top: BorderSide( @@ -1882,7 +1882,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi ), Container( child: Text( - coupon.minAmount > 0 ? + coupon.minAmount! > 0 ? S.of(context).min_order_amount_token( coupon.minAmount) : S.of(context) @@ -1942,7 +1942,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi crossAxisAlignment: CrossAxisAlignment.start, children: [], ); - if (cartInfo.businessInfo.quickInputs.length > 0) { + if (cartInfo!.businessInfo!.quickInputs!.length > 0) { Wrap w = Wrap( children: [], ); @@ -1956,8 +1956,8 @@ class DesktopCheckoutState extends State with SingleTickerProvi ), ), )); - for (int i = 0; i < cartInfo.businessInfo.quickInputs.length; i++) { - String qi = cartInfo.businessInfo.quickInputs[i].value; + for (int i = 0; i < cartInfo!.businessInfo!.quickInputs!.length; i++) { + String qi = cartInfo!.businessInfo!.quickInputs![i].value; w.children.add(TextButton( child: Text( qi, @@ -2137,7 +2137,7 @@ class DesktopCheckoutState extends State with SingleTickerProvi child: Container( alignment: Alignment.centerRight, child: Text( - '${shippingRate.price.toStringAsFixed(2)}', + '${shippingRate.price!.toStringAsFixed(2)}', style: TextStyle( fontSize: 16.0, color: Colors.black38, @@ -2221,14 +2221,14 @@ class DesktopCheckoutState extends State with SingleTickerProvi }, businessId: widget.businessId, body: { - 'cart_id': cartInfo.id, + 'cart_id': cartInfo!.id, 'remark': orderRemark, 'booked_at': bookingTimeList.length > 0 ? bookingTimeList[bookingTimeIndex].unixTime : ( (bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ? 0 : - bookingDateTimeList[bookingDateIndex].bookTimes[bookingTimeIndex] + bookingDateTimeList[bookingDateIndex].bookTimes![bookingTimeIndex] .unixTime ), 'delivery': deliveryMethod, diff --git a/lib/widgets/desktop/desktop_contact_us.dart b/lib/widgets/desktop/desktop_contact_us.dart index d309101..157b5f3 100644 --- a/lib/widgets/desktop/desktop_contact_us.dart +++ b/lib/widgets/desktop/desktop_contact_us.dart @@ -35,7 +35,7 @@ class DesktopContactUsState extends State { String mapUrl = 'https://goo.gl/maps/M365MF5AW35n9ij67'; Completer _controller = Completer(); - LatLng _lastMapPosition; + late LatLng _lastMapPosition; final Set _markers = {}; final Set _polyLine = {}; @@ -253,16 +253,16 @@ class DesktopContactUsState extends State { Container( padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), child: Text( - '${widget.business.address.addressLine1}', + '${widget.business.address!.addressLine1}', ), ) ); - if (widget.business.address.addressLine2 != null && widget.business.address.addressLine2.isNotEmpty) { + if (widget.business.address!.addressLine2 != null && widget.business.address!.addressLine2!.isNotEmpty) { col.children.add( Container( padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), child: Text( - '${widget.business.address.addressLine2}', + '${widget.business.address!.addressLine2}', ), ) ); @@ -271,7 +271,7 @@ class DesktopContactUsState extends State { Container( padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), child: Text( - '${widget.business.address.city}, ${widget.business.address.state}', + '${widget.business.address!.city}, ${widget.business.address!.state}', ), ) ); @@ -279,7 +279,7 @@ class DesktopContactUsState extends State { Container( padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), child: Text( - '${widget.business.address.country}, ${widget.business.address.zip}', + '${widget.business.address!.country}, ${widget.business.address!.zip}', ), ) ); @@ -287,8 +287,8 @@ class DesktopContactUsState extends State { _markers.clear(); _markers.add(Marker( markerId: MarkerId('shop_position'), - position: LatLng(double.parse(widget.business.address.lat), - double.parse(widget.business.address.lng)), + position: LatLng(double.parse(widget.business.address!.lat), + double.parse(widget.business.address!.lng)), infoWindow: InfoWindow( title: S .of(context) @@ -304,8 +304,8 @@ class DesktopContactUsState extends State { onMapCreated: _onMapCreated, initialCameraPosition: CameraPosition( target: LatLng( - double.parse(widget.business.address.lat), - double.parse(widget.business.address.lng)), + double.parse(widget.business.address!.lat), + double.parse(widget.business.address!.lng)), zoom: 14.0, ), onCameraMove: _onCameraMove, diff --git a/lib/widgets/desktop/desktop_coupons.dart b/lib/widgets/desktop/desktop_coupons.dart index d59408d..1cc6f62 100644 --- a/lib/widgets/desktop/desktop_coupons.dart +++ b/lib/widgets/desktop/desktop_coupons.dart @@ -27,7 +27,7 @@ class DesktopCoupons extends StatefulWidget { } class DesktopCouponsState extends State { - List coupons; + late List coupons; double sideSpace = 0; double mainSpace = 1200; @@ -120,7 +120,7 @@ class DesktopCouponsState extends State { Container( padding: EdgeInsets.only(right: 5.0), child: coupon.store != null ? - Util.showImage('${coupon.store.picUrl}', + Util.showImage('${coupon.store!.picUrl}', fit: BoxFit.fill, width: 40.0, ) : @@ -137,7 +137,7 @@ class DesktopCouponsState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - coupon.store != null ? coupon.store.name : S.of(context).general_coupon, + coupon.store != null ? coupon.store!.name : S.of(context).general_coupon, style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, @@ -221,7 +221,7 @@ class DesktopCouponsState extends State { ), Container( child: Text( - coupon.minAmount > 0 ? + coupon.minAmount! > 0 ? S.of(context).available_for_order_over_token(coupon.minAmount) : S.of(context).no_restriction, style: TextStyle( @@ -259,7 +259,7 @@ class DesktopCouponsState extends State { children: [ Container( child: Text( - coupon.expirationDate == null || coupon.expirationDate.length == 0 ? + coupon.expirationDate == null || coupon.expirationDate!.length == 0 ? S.of(context).no_expiration : S.of(context).expiration_date_token(coupon.expirationDate), style: TextStyle( @@ -284,7 +284,7 @@ class DesktopCouponsState extends State { ), onPressed: () { if (coupon.store != null) { - Routes.router.navigateTo(context, '/shop/${coupon.store.id}/na/na/na'); + Routes.router.navigateTo(context, '/shop/${coupon.store!.id}/na/na/na'); } else { Routes.router.navigateTo(context, '/businesses'); } diff --git a/lib/widgets/desktop/desktop_edit_address.dart b/lib/widgets/desktop/desktop_edit_address.dart index 5fff4e7..9e6ae7a 100644 --- a/lib/widgets/desktop/desktop_edit_address.dart +++ b/lib/widgets/desktop/desktop_edit_address.dart @@ -45,12 +45,12 @@ class DesktopEditAddressState extends State { final emailController = TextEditingController(); final faxController = TextEditingController(); - String country; - Gender _selectedGender; + late String country; + late Gender _selectedGender; - String _selectedProvince; + late String _selectedProvince; - bool showLoading; + late bool showLoading; double sideSpace = 0; double mainSpace = 1200; @@ -362,7 +362,7 @@ class DesktopEditAddressState extends State { .email, ), validator: (String? value) { - if (value.isNotEmpty && !EmailValidator.validate(value)) { + if (value!.isNotEmpty && !EmailValidator.validate(value)) { return S .of(context) .email_is_not_valid; diff --git a/lib/widgets/desktop/desktop_forgot_password.dart b/lib/widgets/desktop/desktop_forgot_password.dart index e130b55..b3f4817 100644 --- a/lib/widgets/desktop/desktop_forgot_password.dart +++ b/lib/widgets/desktop/desktop_forgot_password.dart @@ -29,9 +29,9 @@ class DesktopForgotPasswordState extends State { bool usernameEnable = true; final codeController = TextEditingController(); - bool enableGetCode; - String getCodeText; - bool canRegister; + late bool enableGetCode; + late String getCodeText; + late bool canRegister; var countDownListener; @@ -84,7 +84,7 @@ class DesktopForgotPasswordState extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).mobile_or_email_is_required; } return null; @@ -167,7 +167,7 @@ class DesktopForgotPasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).verification_code_is_required; } return null; diff --git a/lib/widgets/desktop/desktop_login.dart b/lib/widgets/desktop/desktop_login.dart index aeedb35..94ea67d 100644 --- a/lib/widgets/desktop/desktop_login.dart +++ b/lib/widgets/desktop/desktop_login.dart @@ -26,9 +26,9 @@ class DesktopLoginState extends State { final usernameController = TextEditingController(); final passwordController = TextEditingController(); - bool passwordVisible; + late bool passwordVisible; - bool onSubmitting; + late bool onSubmitting; double sideSpace = 0; double mainSpace = 1200; @@ -150,7 +150,7 @@ class DesktopLoginState extends State { style: TextStyle(fontSize: 18.0), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).this_field_is_required; } return null; @@ -194,7 +194,7 @@ class DesktopLoginState extends State { style: TextStyle(fontSize: 18.0), obscureText: passwordVisible, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } return null; diff --git a/lib/widgets/desktop/desktop_me.dart b/lib/widgets/desktop/desktop_me.dart index 0082bb9..9f78ebe 100644 --- a/lib/widgets/desktop/desktop_me.dart +++ b/lib/widgets/desktop/desktop_me.dart @@ -16,9 +16,9 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dart'; import '../../utils/utils.dart'; -MediaQueryData mediaQuery; -double statusBarHeight; -double screenHeight; +late MediaQueryData mediaQuery; +late double statusBarHeight; +late double screenHeight; class DesktopMe extends StatefulWidget { final Key? key; @@ -32,11 +32,11 @@ class DesktopMe extends StatefulWidget { } class DesktopMeState extends State { - int userId; - String accessToken; + late int userId; + late String accessToken; - bool isLoading; - User _user; + late bool isLoading; + late User _user; double sideSpace = 0; double mainSpace = 1200; @@ -81,7 +81,7 @@ class DesktopMeState 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}', width: 60, @@ -182,7 +182,7 @@ class DesktopMeState extends State { Container( child: Text( _user != null - ? '${_user.wallet.toStringAsFixed(2)}' + ? '${_user.wallet!.toStringAsFixed(2)}' : '0.00', style: TextStyle( fontSize: 24.0, diff --git a/lib/widgets/desktop/desktop_my_addresses.dart b/lib/widgets/desktop/desktop_my_addresses.dart index 5737666..6b2e481 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 { - List
addresses; + late List
addresses; double sideSpace = 0; double mainSpace = 1200; diff --git a/lib/widgets/desktop/desktop_my_support.dart b/lib/widgets/desktop/desktop_my_support.dart index a79e5f5..b82c9cb 100644 --- a/lib/widgets/desktop/desktop_my_support.dart +++ b/lib/widgets/desktop/desktop_my_support.dart @@ -30,7 +30,7 @@ class DesktopMySupport extends StatefulWidget { } class DesktopMySupportState extends State { - List tickets; + late List tickets; double division = 3; @@ -218,7 +218,7 @@ class DesktopMySupportState extends State { children: [ Container( child: Text( - ticket.issue.msg, + ticket.issue!.msg, style: TextStyle( fontSize: 19.0, ), @@ -248,7 +248,7 @@ class DesktopMySupportState extends State { SizedBox.shrink(), Expanded( child: Text( - S.of(context).followups_token(ticket.followUps.length), + S.of(context).followups_token(ticket.followUps!.length), style: TextStyle( fontSize: 15.0, color: Colors.black87, diff --git a/lib/widgets/desktop/desktop_new_address.dart b/lib/widgets/desktop/desktop_new_address.dart index d3e49d6..f00e018 100644 --- a/lib/widgets/desktop/desktop_new_address.dart +++ b/lib/widgets/desktop/desktop_new_address.dart @@ -39,9 +39,9 @@ class DesktopNewAddressState extends State { final faxController = TextEditingController(); String country = 'CA'; - Gender _selectedGender; + late Gender _selectedGender; - String _selectedProvince; + late String _selectedProvince; double sideSpace = 0; double mainSpace = 1200; @@ -98,7 +98,7 @@ class DesktopNewAddressState extends State { labelText: S.of(context).contact_name, ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).contact_name_is_required; } return null; @@ -142,7 +142,7 @@ class DesktopNewAddressState extends State { labelText: S.of(context).mobile_phone_number, ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).mobile_phone_number_is_required; } return null; @@ -167,7 +167,7 @@ class DesktopNewAddressState extends State { labelText: S.of(context).street_line_1, ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).street_line_1_is_required; } return null; @@ -211,7 +211,7 @@ class DesktopNewAddressState extends State { labelText: S.of(context).city, ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).city_is_required; } return null; @@ -257,7 +257,7 @@ class DesktopNewAddressState extends State { labelText: S.of(context).postal_code, ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).postal_code_is_required; } return null; @@ -292,7 +292,7 @@ class DesktopNewAddressState extends State { labelText: S.of(context).email, ), validator: (String? value) { - if (value.isNotEmpty && !EmailValidator.validate(value)) { + if (value!.isNotEmpty && !EmailValidator.validate(value)) { return S.of(context).email_is_not_valid; } return null; @@ -383,8 +383,8 @@ class DesktopNewAddressState extends State { cityController.text = widget.locatedAddress.city; postalCodeController.text = widget.locatedAddress.postalCode; streetLine1Controller.text = (widget.locatedAddress.streetNumber != null - && widget.locatedAddress.streetNumber.isNotEmpty - ? widget.locatedAddress.streetNumber + ' ' : '') + && widget.locatedAddress.streetNumber!.isNotEmpty + ? widget.locatedAddress.streetNumber! + ' ' : '') + widget.locatedAddress.streetName; } else { _selectedProvince = 'Ontario'; diff --git a/lib/widgets/desktop/desktop_new_comment.dart b/lib/widgets/desktop/desktop_new_comment.dart index 77498f2..3431c6f 100644 --- a/lib/widgets/desktop/desktop_new_comment.dart +++ b/lib/widgets/desktop/desktop_new_comment.dart @@ -34,13 +34,13 @@ class DesktopNewComment extends StatefulWidget { } class DesktopNewCommentState extends State { - Comment comment; + late Comment comment; - bool _showProgress; + late bool _showProgress; - double _progress; + late double _progress; - double rating; + late double rating; bool isSubmitting = false; @@ -203,7 +203,7 @@ class DesktopNewCommentState extends State { children: [], ); - if (comment != null && comment.images.length > 0) { + if (comment != null && comment.images!.length > 0) { for (ProductImage image in comment.images) { row.children.add( Container( @@ -275,7 +275,7 @@ class DesktopNewCommentState extends State { child: Icon( Icons.add, size: 60.0, - color: comment == null || comment.images.length < 3 ? Colors.lightBlue : Colors.black12, + color: comment == null || comment.images!.length < 3 ? Colors.lightBlue : Colors.black12, ), decoration: BoxDecoration( color: Colors.white70, @@ -300,7 +300,7 @@ class DesktopNewCommentState extends State { ), ), onTap: () { - if (comment == null || comment.images.length < 3) { + if (comment == null || comment.images!.length < 3) { showDialog( context: mainContext, barrierDismissible: true, diff --git a/lib/widgets/desktop/desktop_new_ticket.dart b/lib/widgets/desktop/desktop_new_ticket.dart index ec1e40f..ee34820 100644 --- a/lib/widgets/desktop/desktop_new_ticket.dart +++ b/lib/widgets/desktop/desktop_new_ticket.dart @@ -155,7 +155,7 @@ class DesktopNewTicketState extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).this_field_is_required; } return null; diff --git a/lib/widgets/desktop/desktop_new_user.dart b/lib/widgets/desktop/desktop_new_user.dart index de7fbe1..b11fca5 100644 --- a/lib/widgets/desktop/desktop_new_user.dart +++ b/lib/widgets/desktop/desktop_new_user.dart @@ -28,9 +28,9 @@ class DesktopNewUserState extends State { bool usernameEnable = true; final codeController = TextEditingController(); - bool enableGetCode; - String getCodeText; - bool canRegister; + late bool enableGetCode; + late String getCodeText; + late bool canRegister; var countDownListener; @@ -81,7 +81,7 @@ class DesktopNewUserState extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).mobile_or_email_is_required; } return null; @@ -164,7 +164,7 @@ class DesktopNewUserState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).verification_code_is_required; } return null; diff --git a/lib/widgets/desktop/desktop_order_detail.dart b/lib/widgets/desktop/desktop_order_detail.dart index b4f6491..1f62877 100644 --- a/lib/widgets/desktop/desktop_order_detail.dart +++ b/lib/widgets/desktop/desktop_order_detail.dart @@ -39,18 +39,18 @@ class DesktopOrderDetail extends StatefulWidget { } class DesktopOrderDetailState extends State { - Order order; + late Order order; - LatLng _lastMapPosition; - LatLng customerLatLng; - LatLng deliveryLatLng; - LatLng storeLatLng; + late LatLng _lastMapPosition; + late LatLng customerLatLng; + late LatLng deliveryLatLng; + late LatLng storeLatLng; final Set _markers = {}; final Set _polyLine = {}; - BitmapDescriptor homeIcon; - BitmapDescriptor deliveryIcon; - BitmapDescriptor shopIcon; + late BitmapDescriptor homeIcon; + late BitmapDescriptor deliveryIcon; + late BitmapDescriptor shopIcon; double sideSpace = 0; double mainSpace = 1200; @@ -110,7 +110,7 @@ class DesktopOrderDetailState extends State { width: double.infinity, padding: EdgeInsets.only(top: 0.0, bottom: 16.0), child: Text( - order.cartInfo.businessInfo.name, + order.cartInfo!.businessInfo!.name, maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -141,7 +141,7 @@ class DesktopOrderDetailState extends State { Icons.phone, ), onTap: () { - Utils.launchURL('tel:${order.businessInfo.phone}'); + Utils.launchURL('tel:${order.businessInfo!.phone}'); }, ), ), @@ -156,7 +156,7 @@ class DesktopOrderDetailState extends State { child: GoogleMap( onMapCreated: _onMapCreated, initialCameraPosition: CameraPosition( - target: new LatLng(double.parse(order.shippingAddress.lat), double.parse(order.shippingAddress.lng)), + target: new LatLng(double.parse(order.shippingAddress!.lat), double.parse(order.shippingAddress!.lng)), zoom: 11.0, ), onCameraMove: _onCameraMove, @@ -167,14 +167,14 @@ class DesktopOrderDetailState extends State { ].toSet(), ), )); - if (order.deliveryDistance != null && order.deliveryDistance.distance != null) { + if (order.deliveryDistance != null && order.deliveryDistance!.distance != null) { col.children.add(Container( padding: EdgeInsets.only(top: 6.0, bottom: 6.0), margin: EdgeInsets.only(bottom: 6.0), child: Text( S.of(context).delivery_distance_token( - order.deliveryDistance.distance.text, - order.deliveryDistance.duration.text + order.deliveryDistance!.distance!.text, + order.deliveryDistance!.duration!.text ), ), decoration: BoxDecoration( @@ -190,7 +190,7 @@ class DesktopOrderDetailState extends State { } } - for (CartLineItem lineItem in order.cartInfo.productList) { + for (CartLineItem lineItem in order.cartInfo!.productList) { col.children.add(Container( padding: EdgeInsets.only(top: 16.0, bottom: 0.0), @@ -198,7 +198,7 @@ class DesktopOrderDetailState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Util.showImage('${lineItem.product.imagePath}', + Util.showImage('${lineItem.product!.imagePath}', width: 40.0, height: 40.0, fit: BoxFit.fill, @@ -236,7 +236,7 @@ class DesktopOrderDetailState extends State { width: 30.0, alignment: Alignment.centerRight, child: Text( - 'x${lineItem.quantity.round()}', + 'x${lineItem.quantity!.round()}', style: TextStyle( fontSize: 14.0, ), @@ -298,8 +298,8 @@ class DesktopOrderDetailState extends State { ], ), ); - for (var i = 0; i < order.cartInfo.extraFeeList.length; i++) { - ExtraFee extraFee = order.cartInfo.extraFeeList[i]; + for (var i = 0; i < order.cartInfo!.extraFeeList!.length; i++) { + ExtraFee extraFee = order.cartInfo!.extraFeeList![i]; col.children.add( Row( mainAxisAlignment: MainAxisAlignment.start, @@ -323,7 +323,7 @@ class DesktopOrderDetailState extends State { width: 100.0, alignment: Alignment.centerRight, child: Text( - '${extraFee.price.toStringAsFixed(2)}', + '${extraFee.price!.toStringAsFixed(2)}', style: TextStyle( fontSize: 15.0, ), @@ -356,7 +356,7 @@ class DesktopOrderDetailState extends State { width: 100.0, alignment: Alignment.centerRight, child: Text( - '${order.totalPrice.toStringAsFixed(2)}', + '${order.totalPrice!.toStringAsFixed(2)}', style: TextStyle( fontSize: 18.0, fontWeight: FontWeight.bold, @@ -466,7 +466,7 @@ class DesktopOrderDetailState extends State { margin: EdgeInsets.only(top: 10.0, bottom: 10.0), alignment: Alignment.centerRight, child: Text( - '${order.cartInfo.businessInfo.fullAddress}', + '${order.cartInfo!.businessInfo!.fullAddress}', style: TextStyle( color: Colors.black38, ), @@ -893,19 +893,19 @@ class DesktopOrderDetailState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - child: fulfillment.shippingMethod.isNotEmpty && fulfillment.trackingNumber != null && fulfillment.trackingNumber.isNotEmpty ? + child: fulfillment.shippingMethod!.isNotEmpty && fulfillment.trackingNumber != null && fulfillment.trackingNumber!.isNotEmpty ? Text( '${fulfillment.shippingMethod} ${fulfillment.trackingNumber}', overflow: TextOverflow.ellipsis, maxLines: 1, - ) : (fulfillment.shippingMethod.isNotEmpty ? Text( + ) : (fulfillment.shippingMethod!.isNotEmpty ? Text( '${fulfillment.shippingMethod}', overflow: TextOverflow.ellipsis, maxLines: 1, ) : SizedBox.shrink()), ), Container( - child: fulfillment.note != null && fulfillment.note.isNotEmpty ? + child: fulfillment.note != null && fulfillment.note!.isNotEmpty ? Text( '${fulfillment.note}', style: TextStyle( @@ -1092,12 +1092,12 @@ class DesktopOrderDetailState extends State { if (!kIsWeb) { if (order.shippingMethod == 'store-delivery' && order.status != Constants.STATUS_COMPLETE && order.status != Constants.STATUS_CANCELLED) { - storeLatLng = LatLng(double.parse(order.businessInfo.address.lat), - double.parse(order.businessInfo.address.lng)); - customerLatLng = LatLng(double.parse(order.shippingAddress.lat), - double.parse(order.shippingAddress.lng)); + storeLatLng = LatLng(double.parse(order.businessInfo!.address!.lat), + double.parse(order.businessInfo!.address!.lng)); + customerLatLng = LatLng(double.parse(order.shippingAddress!.lat), + double.parse(order.shippingAddress!.lng)); deliveryLatLng = - LatLng(order.shipperPosition.lat, order.shipperPosition.lng); + LatLng(order.shipperPosition!.lat, order.shipperPosition!.lng); _polyLine.clear(); _polyLine.add( @@ -1110,7 +1110,7 @@ class DesktopOrderDetailState extends State { ], width: 3, points: [ - order.shipperPosition.lat != 0.0 ? deliveryLatLng : storeLatLng, + order.shipperPosition!.lat != 0.0 ? deliveryLatLng : storeLatLng, customerLatLng, ] ) @@ -1135,12 +1135,12 @@ class DesktopOrderDetailState extends State { title: S .of(context) .customer, - snippet: order.shippingAddress.addressLine1, + snippet: order.shippingAddress!.addressLine1, ), icon: homeIcon, )); - if (order.shipperPosition.lat != 0.0 && - order.shipperPosition.lng != 0.0) { + if (order.shipperPosition!.lat != 0.0 && + order.shipperPosition!.lng != 0.0) { _markers.add(Marker( markerId: MarkerId('shipper_position'), position: deliveryLatLng, diff --git a/lib/widgets/desktop/desktop_orders.dart b/lib/widgets/desktop/desktop_orders.dart index 0ad46a7..541766d 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(); - List orders; + late List orders; bool _isLoading = false; @@ -181,7 +181,7 @@ class DesktopOrdersState extends State with SingleTickerProviderS row.children.add(Expanded( child: Container( child: Text( - order.cartInfo.productList[0].name, + order.cartInfo!.productList![0].name, style: TextStyle( fontSize: 14.0, ), @@ -190,7 +190,7 @@ class DesktopOrdersState extends State with SingleTickerProviderS ), ), )); - if (order.cartInfo.productList.length > 1) { + if (order.cartInfo!.productList!.length > 1) { row.children.add(Container( child: Text( S.of(context).and_more_item_token(Utils.getProductLineInOrder(order.cartInfo)), @@ -205,7 +205,7 @@ class DesktopOrdersState extends State with SingleTickerProviderS width: 80.0, alignment: Alignment.centerRight, child: Text( - '\$${order.totalPrice.toStringAsFixed(2)}', + '\$${order.totalPrice!.toStringAsFixed(2)}', style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -320,7 +320,7 @@ class DesktopOrdersState extends State with SingleTickerProviderS mainAxisAlignment: MainAxisAlignment.start, children: [ Container( - child: Util.showImage('${order.cartInfo.businessInfo.picUrl}', + child: Util.showImage('${order.cartInfo!.businessInfo!.picUrl}', width: 32.0, height: 32.0, fit: BoxFit.fill, @@ -336,7 +336,7 @@ class DesktopOrdersState extends State with SingleTickerProviderS children: [ Container( child: Text( - '${order.cartInfo.businessInfo.name}', + '${order.cartInfo!.businessInfo!.name}', style: TextStyle( fontSize: 20.0, ), diff --git a/lib/widgets/desktop/desktop_pay_now.dart b/lib/widgets/desktop/desktop_pay_now.dart index e9d2dea..fe5d935 100644 --- a/lib/widgets/desktop/desktop_pay_now.dart +++ b/lib/widgets/desktop/desktop_pay_now.dart @@ -32,9 +32,9 @@ class DesktopPayNow extends StatefulWidget { } class DesktopPayNowState extends State { - Order order; - List paymentPlatforms; - User _user; + late Order order; + late List paymentPlatforms; + late User _user; double sideSpace = 0; double mainSpace = 1200; @@ -86,7 +86,7 @@ class DesktopPayNowState extends State { ), ), Text( - '\$${order.totalPrice.toStringAsFixed(2)}', + '\$${order.totalPrice!.toStringAsFixed(2)}', style: TextStyle( fontSize: 24.0, fontWeight: FontWeight.bold, @@ -103,7 +103,7 @@ class DesktopPayNowState extends State { ) ), ), - store.state.deviceId != null && store.state.deviceId.isNotEmpty || store.state.tableNumber != null && store.state.tableNumber.isNotEmpty ? + store.state.deviceId != null && store.state.deviceId!.isNotEmpty || store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty ? GestureDetector( child: Container( padding: EdgeInsets.only(top: 20.0, bottom: 20.0, left: 16.0, right: 16.0), diff --git a/lib/widgets/desktop/desktop_product_detail_page.dart b/lib/widgets/desktop/desktop_product_detail_page.dart index d5ca31e..e716ad0 100644 --- a/lib/widgets/desktop/desktop_product_detail_page.dart +++ b/lib/widgets/desktop/desktop_product_detail_page.dart @@ -42,13 +42,13 @@ class DesktopProductDetailPage extends StatefulWidget { class DesktopProductDetailPageState extends State with SingleTickerProviderStateMixin { - TabController _tabController; + late TabController _tabController; final double _tabBarHeight = 50; - ProductDetail productDetail; + late ProductDetail productDetail; - bool refresh; + late bool refresh; double sideSpace = 0; double mainSpace = 1200; @@ -207,7 +207,7 @@ class DesktopProductDetailPageState extends State mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - (productDetail.subproducts.length > 0) ? + (productDetail.subproducts!.length > 0) ? subProducts(productDetail.subproducts) : SizedBox.shrink(), Container( @@ -222,7 +222,7 @@ class DesktopProductDetailPageState extends State Container( padding: EdgeInsets.only(left: 10.0, right: 10.0), child: (productDetail.description2 != null && - !productDetail.description2.isEmpty) + !productDetail.description2!.isEmpty) ? Text( '${productDetail.description2}', style: TextStyle( @@ -299,7 +299,7 @@ class DesktopProductDetailPageState extends State } Widget getImage(double width) { - if (productDetail.images.length <= 0) { + if (productDetail.images!.length <= 0) { return Util.showImage( productDetail.image, width: width, @@ -346,7 +346,7 @@ class DesktopProductDetailPageState extends State Container( padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 5.0), child: Util.showImage( - 'https:${subproduct.product.image}', + 'https:${subproduct.product!.image}', width: 48, height: 48, fit: BoxFit.contain, @@ -366,7 +366,7 @@ class DesktopProductDetailPageState extends State child: Container( padding: EdgeInsets.only(left: 12, top: 5), child: Text( - subproduct.product.name, + subproduct.product!.name, style: TextStyle( fontSize: 15.0, ), @@ -377,7 +377,7 @@ class DesktopProductDetailPageState extends State width: 80, padding: EdgeInsets.only(left: 12, top: 5, right: 12), child: Text( - '${subproduct.product.price.toStringAsFixed(2)}', + '${subproduct.product!.price!.toStringAsFixed(2)}', style: TextStyle( fontSize: 13, decoration: TextDecoration.lineThrough, @@ -389,7 +389,7 @@ class DesktopProductDetailPageState extends State width: 60, padding: EdgeInsets.only(left: 12, top: 5, right: 12), child: Text( - 'x${subproduct.quantity.toStringAsFixed(0)}', + 'x${subproduct.quantity!.toStringAsFixed(0)}', style: TextStyle( fontSize: 13, ), @@ -401,7 +401,7 @@ class DesktopProductDetailPageState extends State Container( padding: EdgeInsets.only(left: 12, top: 12, right: 12), child: Text( - '${subproduct.product.description}', + '${subproduct.product!.description}', style: TextStyle( fontSize: 12, color: Colors.black45, @@ -453,9 +453,9 @@ class DesktopProductDetailPageState extends State var pages = []; List images = []; images.add(productDetail.image); - for (var i = 0; i < productDetail.images.length; i++) { + for (var i = 0; i < productDetail.images!.length; i++) { // print('>>https:' + productDetail.images[i].image); - images.add(productDetail.images[i].image); + images.add(productDetail.images![i].image); } for (var i = 0; i < images.length; i++) { diff --git a/lib/widgets/desktop/desktop_product_item.dart b/lib/widgets/desktop/desktop_product_item.dart index 8398113..b2e1c7f 100644 --- a/lib/widgets/desktop/desktop_product_item.dart +++ b/lib/widgets/desktop/desktop_product_item.dart @@ -109,7 +109,7 @@ class DesktopProductItemState extends State { new Container( child: widget.business.showMonthlySold ? Text( - S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), + S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)), style: new TextStyle( fontSize: 9.0 ), @@ -193,7 +193,7 @@ class DesktopProductItemState extends State { new Container( child: widget.business.showMonthlySold ? Text( - S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), + S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)), style: new TextStyle( fontSize: 9.0 ), diff --git a/lib/widgets/desktop/desktop_renew_license.dart b/lib/widgets/desktop/desktop_renew_license.dart index 9eb2026..34a2315 100644 --- a/lib/widgets/desktop/desktop_renew_license.dart +++ b/lib/widgets/desktop/desktop_renew_license.dart @@ -134,7 +134,7 @@ class DesktopRenewLicenseState extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).please_enter_group_number; } return null; diff --git a/lib/widgets/desktop/desktop_reset_password.dart b/lib/widgets/desktop/desktop_reset_password.dart index 0f3762d..71e211c 100644 --- a/lib/widgets/desktop/desktop_reset_password.dart +++ b/lib/widgets/desktop/desktop_reset_password.dart @@ -26,10 +26,10 @@ class DesktopResetPasswordState extends State { final passwordController = TextEditingController(); final passwordAgainController = TextEditingController(); - bool passwordVisible; - bool passwordAgainVisible; + late bool passwordVisible; + late bool passwordAgainVisible; - bool canReset; + late bool canReset; double sideSpace = 0; double mainSpace = 1200; @@ -93,7 +93,7 @@ class DesktopResetPasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } return null; @@ -147,10 +147,10 @@ class DesktopResetPasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } - if (value.trim() != passwordController.text.trim()) { + if (value!.trim() != passwordController.text.trim()) { return S.of(context).password_is_not_match_password_again; } return null; diff --git a/lib/widgets/desktop/desktop_search_place.dart b/lib/widgets/desktop/desktop_search_place.dart index 4bf6090..59b9dc4 100644 --- a/lib/widgets/desktop/desktop_search_place.dart +++ b/lib/widgets/desktop/desktop_search_place.dart @@ -128,7 +128,7 @@ class DesktopSearchPlaceState extends State { ); if (result is DioError) { if (result.response != null) { - throw RuntimeError(result.response.data['message']); + throw RuntimeError(result.response!.data['message']); } else { throw RuntimeError(result.message); } diff --git a/lib/widgets/desktop/desktop_set_password.dart b/lib/widgets/desktop/desktop_set_password.dart index 0c10c9d..2910c98 100644 --- a/lib/widgets/desktop/desktop_set_password.dart +++ b/lib/widgets/desktop/desktop_set_password.dart @@ -26,10 +26,10 @@ class DesktopSetPasswordState extends State { final passwordController = TextEditingController(); final passwordAgainController = TextEditingController(); - bool passwordVisible; - bool passwordAgainVisible; + late bool passwordVisible; + late bool passwordAgainVisible; - bool canReset; + late bool canReset; double sideSpace = 0; double mainSpace = 1200; @@ -93,7 +93,7 @@ class DesktopSetPasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } return null; @@ -147,10 +147,10 @@ class DesktopSetPasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } - if (value.trim() != passwordController.text.trim()) { + if (value!.trim() != passwordController.text.trim()) { return S.of(context).password_is_not_match_password_again; } return null; diff --git a/lib/widgets/desktop/desktop_shopping_cart_widget.dart b/lib/widgets/desktop/desktop_shopping_cart_widget.dart index db3f00a..64998c6 100644 --- a/lib/widgets/desktop/desktop_shopping_cart_widget.dart +++ b/lib/widgets/desktop/desktop_shopping_cart_widget.dart @@ -18,14 +18,14 @@ class DesktopShoppingCartWidget extends StatefulWidget { } class DesktopShoppingCartWidgetState extends State { - 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(); } Row row = Row( diff --git a/lib/widgets/desktop/desktop_store_product_search.dart b/lib/widgets/desktop/desktop_store_product_search.dart index cac7c03..5deedda 100644 --- a/lib/widgets/desktop/desktop_store_product_search.dart +++ b/lib/widgets/desktop/desktop_store_product_search.dart @@ -134,7 +134,7 @@ class DesktopStoreProductSearchState extends State { ); if (result is DioError) { if (result.response != null) { - throw RuntimeError(result.response.data); + throw RuntimeError(result.response!.data); } else { throw RuntimeError(result.message); } diff --git a/lib/widgets/desktop/desktop_user_profile.dart b/lib/widgets/desktop/desktop_user_profile.dart index 4e53ba2..38aba47 100644 --- a/lib/widgets/desktop/desktop_user_profile.dart +++ b/lib/widgets/desktop/desktop_user_profile.dart @@ -27,10 +27,10 @@ class DesktopUserProfile extends StatefulWidget { } class DesktopUserProfileState extends State { - User _user; + late User _user; - bool _showProgress; - double _progress; + late bool _showProgress; + late double _progress; double sideSpace = 0; double mainSpace = 1200; @@ -253,7 +253,7 @@ class DesktopUserProfileState extends State { ), Container( child: Text( - _user.mobile != null && _user.mobile.isNotEmpty ? Utils.safePhoneNumber(_user.mobile) : S.of(context).not_binding, + _user.mobile != null && _user.mobile!.isNotEmpty ? Utils.safePhoneNumber(_user.mobile) : S.of(context).not_binding, style: TextStyle( color: Colors.grey, ), @@ -306,7 +306,7 @@ class DesktopUserProfileState extends State { ), Container( child: Text( - _user.email != null && _user.email.isNotEmpty ? Utils.safePhoneNumber(_user.email) : S.of(context).not_binding, + _user.email != null && _user.email!.isNotEmpty ? Utils.safePhoneNumber(_user.email) : S.of(context).not_binding, style: TextStyle( color: Colors.grey, ), @@ -425,7 +425,7 @@ class DesktopUserProfileState extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).nickname_is_required; } return null; diff --git a/lib/widgets/desktop/desktop_view_blog.dart b/lib/widgets/desktop/desktop_view_blog.dart index f1cebd0..8bde1d3 100644 --- a/lib/widgets/desktop/desktop_view_blog.dart +++ b/lib/widgets/desktop/desktop_view_blog.dart @@ -28,7 +28,7 @@ class DesktopViewBlog extends StatefulWidget { } class DesktopViewBlogState extends State { - Blog blog; + late Blog blog; double sideSpace = 0; double mainSpace = 1200; diff --git a/lib/widgets/desktop/desktop_view_ticket.dart b/lib/widgets/desktop/desktop_view_ticket.dart index 54b6a5f..b765a65 100644 --- a/lib/widgets/desktop/desktop_view_ticket.dart +++ b/lib/widgets/desktop/desktop_view_ticket.dart @@ -33,7 +33,7 @@ class DesktopViewTicket extends StatefulWidget { class DesktopViewTicketState extends State { final GlobalKey _formKey = GlobalKey(); - Ticket ticket; + late Ticket ticket; final issueMsgController = TextEditingController(); @@ -144,7 +144,7 @@ class DesktopViewTicketState extends State { ), autofocus: false, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).this_field_is_required; } return null; @@ -240,7 +240,7 @@ class DesktopViewTicketState extends State { width: double.maxFinite, padding: EdgeInsets.only(top: 8.0, left: 16.0, right: 16.0, bottom: 24.0), child: Text( - '${ticket.issue.msg}', + '${ticket.issue!.msg}', style: TextStyle( color: Colors.black54, fontSize: 14.0, @@ -260,7 +260,7 @@ class DesktopViewTicketState extends State { padding: EdgeInsets.only(top: 16.0, bottom: 16.0, left: 16.0, right: 16.0), child: SingleChildScrollView( scrollDirection: Axis.horizontal, - child: showGalleryImages(mainContext, ticket.issue.files), + child: showGalleryImages(mainContext, ticket.issue!.files), ), decoration: BoxDecoration( border: Border( @@ -291,7 +291,7 @@ class DesktopViewTicketState extends State { ], ); - if (ticket.followUps.length > 0) { + if (ticket.followUps!.length > 0) { ticketCol.children.add( Container( width: double.maxFinite, @@ -305,8 +305,8 @@ class DesktopViewTicketState extends State { ), ), ); - for (int i = 0; i < ticket.followUps.length; i++) { - FollowUp followUp = ticket.followUps[i]; + for (int i = 0; i < ticket.followUps!.length; i++) { + FollowUp followUp = ticket.followUps![i]; ticketCol.children.add( Container( width: double.maxFinite, @@ -423,7 +423,7 @@ class DesktopViewTicketState extends State { padding: EdgeInsets.only(left: 20.0, right: 20.0, top: 0.0, bottom: 30.0), child: TextLink( S.of(context).new_ticket, - '/new-ticket/${ticket.store.id}', + '/new-ticket/${ticket.store!.id}', ), ) ], @@ -693,7 +693,7 @@ class DesktopViewTicketState extends State { child: Text(S.of(context).ok), onPressed: () { Routes.router.navigateTo(context, - '/my-support/${ticket.store.id}', + '/my-support/${ticket.store!.id}', replace: true, ); }, diff --git a/lib/widgets/desktop/product_item.dart b/lib/widgets/desktop/product_item.dart index 919bc5c..e35752f 100644 --- a/lib/widgets/desktop/product_item.dart +++ b/lib/widgets/desktop/product_item.dart @@ -90,7 +90,7 @@ class ProductItemState extends State { width: 110.0, height: 110.0, child: GestureDetector( - child: onHover && widget.product.secondImagePath.isNotEmpty ? + child: onHover && widget.product.secondImagePath!.isNotEmpty ? Util.showImage('${widget.product.secondImagePath}', fit: BoxFit.fill, ) : @@ -143,7 +143,7 @@ class ProductItemState extends State { new Container( child: widget.business.showMonthlySold ? Text( - S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), + S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)), style: new TextStyle( fontSize: 9.0 ), @@ -176,7 +176,7 @@ class ProductItemState extends State { width: 110.0, height: 110.0, child: GestureDetector( - child: onHover && widget.product.secondImagePath.isNotEmpty ? + child: onHover && widget.product.secondImagePath!.isNotEmpty ? Util.showImage('${widget.product.secondImagePath}', fit: BoxFit.fill, ) : @@ -231,7 +231,7 @@ class ProductItemState extends State { new Container( child: widget.business.showMonthlySold ? Text( - S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), + S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)), style: new TextStyle( fontSize: 9.0 ), diff --git a/lib/widgets/desktop/product_search.dart b/lib/widgets/desktop/product_search.dart index a7486bc..9cdf7de 100644 --- a/lib/widgets/desktop/product_search.dart +++ b/lib/widgets/desktop/product_search.dart @@ -142,7 +142,7 @@ class ProductSearchState extends State { ); if (result is DioError) { if (result.response != null) { - throw RuntimeError(result.response.data); + throw RuntimeError(result.response!.data); } else { throw RuntimeError(result.message); } diff --git a/lib/widgets/desktop/shop.dart b/lib/widgets/desktop/shop.dart index 7c85306..21ea92d 100644 --- a/lib/widgets/desktop/shop.dart +++ b/lib/widgets/desktop/shop.dart @@ -32,13 +32,13 @@ class Shop extends StatefulWidget { } class ShopState extends State { - Business _business; + late Business _business; PanelController panelController = PanelController(); - SlidingUpPanel _slidUpShoppingCart; + late SlidingUpPanel _slidUpShoppingCart; GlobalKey endKey = GlobalKey(); - List _categoryProducts; + late List _categoryProducts; bool displayProductByCategoryClick = false; String displayProductByCategoryClickIndicator = ''; int categoryId = 0; @@ -261,7 +261,7 @@ class ShopState extends State { if (moreCategoryProducts.isEmpty) { _productCurrentPage = 0; } else { - if (moreCategoryProducts[0].products.length < Constants.ORDERS_PER_PAGE) { + if (moreCategoryProducts[0].products!.length < Constants.ORDERS_PER_PAGE) { _productCurrentPage = 0; } } diff --git a/lib/widgets/desktop/shop_bulletin.dart b/lib/widgets/desktop/shop_bulletin.dart index cef770a..f2cc3ea 100644 --- a/lib/widgets/desktop/shop_bulletin.dart +++ b/lib/widgets/desktop/shop_bulletin.dart @@ -28,7 +28,7 @@ class ShopBulletinState extends State { sideSpace = (MediaQuery.of(context).size.width - 1200) / 2; } - if (widget.business.bulletin != null && widget.business.bulletin.isNotEmpty) { + if (widget.business.bulletin != null && widget.business.bulletin!.isNotEmpty) { return Container( margin: EdgeInsets.only(bottom: 12), child: Row( diff --git a/lib/widgets/desktop/shop_products.dart b/lib/widgets/desktop/shop_products.dart index a14b2ee..666fa36 100644 --- a/lib/widgets/desktop/shop_products.dart +++ b/lib/widgets/desktop/shop_products.dart @@ -39,7 +39,7 @@ class ShopProductsState extends State { int _categoryIndex = 0; List _categoryProducts = []; - Business _business; + late Business _business; double menuPosition = 0; @@ -116,11 +116,11 @@ class ShopProductsState extends State { int qtyInCategory = 0; CartInfo cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, _business); if (cartInfo != null && - cartInfo.businessInfo.id == _business.id && + cartInfo.businessInfo!.id == _business.id && cartInfo.productList != null) { - for (var i = 0; i < cartInfo.productList.length; i++) { - if (cartInfo.productList[i].product.categoryId == cp.id) { - qtyInCategory += cartInfo.productList[i].quantity.ceil(); + for (var i = 0; i < cartInfo.productList!.length; i++) { + if (cartInfo.productList![i].product!.categoryId == cp.id) { + qtyInCategory += cartInfo.productList![i].quantity!.ceil(); } } } @@ -205,7 +205,7 @@ class ShopProductsState extends State { ); for (int i = 0; i < _categoryProducts.length; i++) { CategoryProducts cp = _categoryProducts[i]; - if (cp.products.length > 0) { + if (cp.products!.length > 0) { col.children.add(new Container( height: _categoryDescHeight, padding: new EdgeInsets.symmetric(horizontal: 10.0), @@ -239,7 +239,7 @@ class ShopProductsState extends State { ), ), new Visibility( - visible: cp.description.isNotEmpty, + visible: cp.description!.isNotEmpty, child: new Text( cp.description, overflow: TextOverflow.ellipsis, @@ -253,8 +253,8 @@ class ShopProductsState extends State { ], ))); - var it = cp.products.iterator; - for (int i = 0; i < cp.products.length; i++) { + var it = cp.products!.iterator; + for (int i = 0; i < cp.products!.length; i++) { var r1 = Row( mainAxisAlignment: MainAxisAlignment.start, children: [], @@ -295,7 +295,7 @@ class ShopProductsState extends State { ), ); } else if (categoryId > 0) { - if (cp.products.length < Constants.ORDERS_PER_PAGE) { + if (cp.products!.length < Constants.ORDERS_PER_PAGE) { col.children.add( Container( padding: EdgeInsets.all(12.0), @@ -374,7 +374,7 @@ class ShopProductsState extends State { .of(context) .end_of_the_list; } else { - if (moreCategoryProducts[0].products.length < + if (moreCategoryProducts[0].products!.length < Constants.ORDERS_PER_PAGE) { displayProductByCategoryClickIndicator = S .of(context) @@ -388,7 +388,7 @@ class ShopProductsState extends State { CategoryProducts currentCp = getCategoryProductByCategoryId(categoryId); if (currentCp != null) { - currentCp.products.addAll(moreCategoryProducts[0].products); + currentCp.products!.addAll(moreCategoryProducts[0].products); } else { displayProductByCategoryClickIndicator = S .of(context) @@ -403,7 +403,7 @@ class ShopProductsState extends State { int numCategoriesHasProducts() { int num = 0; for (CategoryProducts cp in _categoryProducts) { - if (cp.products.length > 0) { + if (cp.products!.length > 0) { num += 1; } } diff --git a/lib/widgets/desktop/shop_promote.dart b/lib/widgets/desktop/shop_promote.dart index 8849ccf..0971f94 100644 --- a/lib/widgets/desktop/shop_promote.dart +++ b/lib/widgets/desktop/shop_promote.dart @@ -22,7 +22,7 @@ class ShopPromoteState extends State { double sideSpace = 0; double mainSpace = 1200; - Business _business; + late Business _business; @override Widget build(BuildContext context) { @@ -90,7 +90,7 @@ class ShopPromoteState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [], ); - for (var i = 0; i < _business.promoProducts.length; i++) { + for (var i = 0; i < _business.promoProducts!.length; i++) { promotRow.children.add(Container( padding: EdgeInsets.only( left: 10.0, @@ -129,17 +129,17 @@ class ShopPromoteState extends State { GestureDetector( child: Container( child: Util.showImage( - _business.promoProducts[i].imagePath, + _business.promoProducts![i].imagePath, width: 120.0, ), ), onTap: () { - _showProductDetail(_business.promoProducts[i]); + _showProductDetail(_business.promoProducts![i]); }, ), Container( child: Text( - _business.promoProducts[i].name, + _business.promoProducts![i].name, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 14.0), @@ -149,16 +149,16 @@ class ShopPromoteState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ ShowPrice( - _business.promoProducts[i].price, + _business.promoProducts![i].price, currencySign: '\$', fontWeight: FontWeight.bold, smallFontSize: 15, largeFontSize: 24, - regularPrice: _business.promoProducts[i].regularPrice, + regularPrice: _business.promoProducts![i].regularPrice, ), Container( child: AddRemoveButton( - product: _business.promoProducts[i], + product: _business.promoProducts![i], business: _business, addOnly: true, ), diff --git a/lib/widgets/desktop/shopping_cart_widget.dart b/lib/widgets/desktop/shopping_cart_widget.dart index 739a918..0813f12 100644 --- a/lib/widgets/desktop/shopping_cart_widget.dart +++ b/lib/widgets/desktop/shopping_cart_widget.dart @@ -19,14 +19,14 @@ class ShoppingCartWidget extends StatefulWidget { } class ShoppingCartWidgetState extends State { - 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(); } Row row = Row( diff --git a/lib/widgets/general/add_remove_button.dart b/lib/widgets/general/add_remove_button.dart index 78cc8aa..2d7833a 100644 --- a/lib/widgets/general/add_remove_button.dart +++ b/lib/widgets/general/add_remove_button.dart @@ -40,7 +40,7 @@ class AddRemoveButton extends StatefulWidget { } class AddRemoveButtonState extends State { - 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 { var d = 1; - CartInfo cartInfo; + late CartInfo cartInfo; GlobalKey startKey = GlobalKey(); @@ -63,10 +63,10 @@ class AddRemoveButtonState extends State { _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 { ), ); } - 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 { _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 { _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 { 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 { 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 { 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 { } 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))); diff --git a/lib/widgets/general/animation_point_manager.dart b/lib/widgets/general/animation_point_manager.dart index 6b98a0b..321e3bc 100644 --- a/lib/widgets/general/animation_point_manager.dart +++ b/lib/widgets/general/animation_point_manager.dart @@ -5,8 +5,8 @@ import 'popup_animation_widget.dart'; class AnimationPointManager { List list = []; - static AnimationController controller1; - static AnimationController controller2; + static late AnimationController controller1; + static late AnimationController controller2; Future addParabolicAniamtion({ @required TickerProvider vsync, @@ -55,9 +55,9 @@ class AnimationPointManager { @required GlobalKey stackKey, @required GlobalKey startKey, @required Widget child, - Duration duration, + Duration? duration, Offset popupOffset = Offset.zero, - AnimationStatusListener statusListener, + AnimationStatusListener? statusListener, }) async { controller2 = createController(vsync, duration); diff --git a/lib/widgets/general/attribute/check_options.dart b/lib/widgets/general/attribute/check_options.dart index 1280837..f7f9ce7 100644 --- a/lib/widgets/general/attribute/check_options.dart +++ b/lib/widgets/general/attribute/check_options.dart @@ -50,14 +50,14 @@ class CheckOptionsState extends OptionsBaseState { crossAxisAlignment: CrossAxisAlignment.start, children: [ new Text( - S.of(context).check_option_select_token(product.productAttributes[this.index].name), + S.of(context).check_option_select_token(product.productAttributes![this.index].name), style: new TextStyle( fontSize: 12.5, ), overflow: TextOverflow.ellipsis, ), new Text( - product.productAttributes[this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional, + product.productAttributes![this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional, style: new TextStyle( fontSize: 10.0, color: new Color(0xFF999999) @@ -95,20 +95,20 @@ class CheckOptionsState extends OptionsBaseState { 'adjust_amount': adjustAmount }; var cloneSelections = json.decode(json.encode(selections)); - int idx = Utils.selectionsContains(cloneSelections, product.productAttributes[index].name, name); + int idx = Utils.selectionsContains(cloneSelections, product.productAttributes![index].name, name); if (idx != -1) { - (cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).removeAt(idx); - } else if (cloneSelections.containsKey(product.productAttributes[index].name.toUpperCase())) { - (cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).add(opt); + (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).removeAt(idx); + } else if (cloneSelections.containsKey(product.productAttributes![index].name!.toUpperCase())) { + (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).add(opt); } else { - cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt]; + cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt]; } - if (idx != -1 && (cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).length == 0) { - cloneSelections.remove(product.productAttributes[index].name.toUpperCase()); + if (idx != -1 && (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).length == 0) { + cloneSelections.remove(product.productAttributes![index].name!.toUpperCase()); } - setOptionsStateDisabled(product.productAttributes[index].name, false); + setOptionsStateDisabled(product.productAttributes![index].name, false); setState(() { selections = cloneSelections; @@ -121,20 +121,20 @@ class CheckOptionsState extends OptionsBaseState { children: [], ); - List productOptions = product.productAttributes[index].productOptions; + List productOptions = product.productAttributes![index].productOptions; - if (!optionsState.containsKey(product.productAttributes[index].name)) { + if (!optionsState.containsKey(product.productAttributes![index].name)) { List> optionState = []; for (var i = 0; i < productOptions.length; i++) { - optionState.add({'name': product.productAttributes[index].productOptions[i].name, 'disabled': false, 'check': false}); + optionState.add({'name': product.productAttributes![index].productOptions![i].name, 'disabled': false, 'check': false}); } - optionsState[product.productAttributes[index].name] = optionState; + optionsState[product.productAttributes![index].name] = optionState; } - if (selections.containsKey(product.productAttributes[index].name.toUpperCase())) { + if (selections.containsKey(product.productAttributes![index].name!.toUpperCase())) { Map attrExtraJson = Utils.stringToJson( - product.productAttributes[index].extra); + product.productAttributes![index].extra); if (attrExtraJson != null) { var selectLimitIfFieldEqualsTo = Rule.getRule( attrExtraJson, Rule.RULE_SELECT_LIMIT_IF_FIELD_EQUALS_TO); @@ -147,7 +147,7 @@ class CheckOptionsState extends OptionsBaseState { int limitQty = selectLimitIfFieldEqualsTo1[Rule .RULE_KEY_FORCE_LIMITED]; thisLimitQty = limitQty; - if ((selections[product.productAttributes[index].name + if ((selections[product.productAttributes![index].name .toUpperCase()] as List).length >= limitQty) { disableOptionIfNotSelected(); } @@ -155,7 +155,7 @@ class CheckOptionsState extends OptionsBaseState { if (selectLimitIfFieldEqualsTo1.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0])) { int limitQty = selectLimitIfFieldEqualsTo1[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0]]; thisLimitQty = limitQty; - if ((selections[product.productAttributes[index].name + if ((selections[product.productAttributes![index].name .toUpperCase()] as List).length >= limitQty) { disableOptionIfNotSelected(); } @@ -168,7 +168,7 @@ class CheckOptionsState extends OptionsBaseState { int limitQty = selectLimitIfFieldEqualsTo[Rule .RULE_KEY_FORCE_LIMITED]; thisLimitQty = limitQty; - if ((selections[product.productAttributes[index].name + if ((selections[product.productAttributes![index].name .toUpperCase()] as List).length >= limitQty) { disableOptionIfNotSelected(); } @@ -176,7 +176,7 @@ class CheckOptionsState extends OptionsBaseState { if (selectLimitIfFieldEqualsTo.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0])) { int limitQty = selectLimitIfFieldEqualsTo[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0]]; thisLimitQty = limitQty; - if ((selections[product.productAttributes[index].name + if ((selections[product.productAttributes![index].name .toUpperCase()] as List).length >= limitQty) { disableOptionIfNotSelected(); } @@ -195,12 +195,12 @@ class CheckOptionsState extends OptionsBaseState { Map multiItemRule = Rule.getRule(extraJson, Rule.RULE_ACTUAL_QTY_IS); if (exclusiveRule != null) { if (thisLimitQty > 0 && !_checkOptionIsCheck(productOptions[i].name)) { - optionsState[product.productAttributes[index].name][i]['disabled'] = true; + optionsState[product.productAttributes![index].name][i]['disabled'] = true; } else { if (_checkOptionIsCheck(productOptions[i].name)) { setOptionsStateDisabled( - product.productAttributes[index].name, true); - optionsState[product.productAttributes[index] + product.productAttributes![index].name, true); + optionsState[product.productAttributes![index] .name][i]['disabled'] = false; break; } @@ -208,12 +208,12 @@ class CheckOptionsState extends OptionsBaseState { } if (multiItemRule != null) { if (_checkOptionIsCheck(productOptions[i].name)) { - if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) { + if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes![index].name!.toUpperCase()] as List).length) { disableOptionIfNotSelected(); } } else { - if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) { - optionsState[product.productAttributes[index] + if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes![index].name!.toUpperCase()] as List).length) { + optionsState[product.productAttributes![index] .name][i]['disabled'] = true; } } @@ -222,26 +222,26 @@ class CheckOptionsState extends OptionsBaseState { } } - List> optionState = optionsState[product.productAttributes[index].name]; + List> optionState = optionsState[product.productAttributes![index].name]; for (var i = 0; i < optionState.length; i++) { Widget optionWidget = _getOptionCheck( - product.productAttributes[index].productOptions[i], optionState[i]['disabled'], i); + product.productAttributes![index].productOptions![i], optionState[i]['disabled'], i); row.children.add(optionWidget); } return row; } void disableOptionIfNotSelected() { - setOptionsStateDisabled(product.productAttributes[index].name, true); - for (var i = 0; i < optionsState[product.productAttributes[index].name].length; i++) { - if (Utils.selectionsContains(selections, product.productAttributes[index].name, optionsState[product.productAttributes[index].name][i]['name']) != -1) { - optionsState[product.productAttributes[index].name][i]['disabled'] = false; + setOptionsStateDisabled(product.productAttributes![index].name, true); + for (var i = 0; i < optionsState[product.productAttributes![index].name].length; i++) { + if (Utils.selectionsContains(selections, product.productAttributes![index].name, optionsState[product.productAttributes![index].name][i]['name']) != -1) { + optionsState[product.productAttributes![index].name][i]['disabled'] = false; } } } bool _checkOptionIsCheck(String name) { - if (Utils.selectionsContains(selections, product.productAttributes[index].name, name) != -1) { + if (Utils.selectionsContains(selections, product.productAttributes![index].name, name) != -1) { return true; } return false; @@ -343,7 +343,7 @@ class CheckOptionsState extends OptionsBaseState { overflow: TextOverflow.ellipsis, ), new Text( - (productOption.adjustAmount + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount + extraAdjustAmount).toStringAsFixed(2)}' : '', + (productOption.adjustAmount! + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount! + extraAdjustAmount).toStringAsFixed(2)}' : '', style: new TextStyle( fontSize: 11.0, color: check ? selectedTextColor : new Color(0xFFABABAB), @@ -354,7 +354,7 @@ class CheckOptionsState extends OptionsBaseState { ), ), onTap: () => disabled ? null : _onOptionTappedCallback( - productOption.name, 0, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption), + productOption.name, 0, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption), ); } diff --git a/lib/widgets/general/attribute/options_base.dart b/lib/widgets/general/attribute/options_base.dart index b9d5de9..be2638f 100644 --- a/lib/widgets/general/attribute/options_base.dart +++ b/lib/widgets/general/attribute/options_base.dart @@ -16,9 +16,9 @@ abstract class OptionsBase extends StatefulWidget { } abstract class OptionsBaseState extends State { - Product product; - Map selections; - int index; + late Product product; + late Map selections; + late int index; final Color disabledBackgroundColor = new Color(0xFFBCBCBC); diff --git a/lib/widgets/general/attribute/qty_options.dart b/lib/widgets/general/attribute/qty_options.dart index 8d99ca6..bd06cea 100644 --- a/lib/widgets/general/attribute/qty_options.dart +++ b/lib/widgets/general/attribute/qty_options.dart @@ -41,14 +41,14 @@ class QtyOptionsState extends OptionsBaseState { crossAxisAlignment: CrossAxisAlignment.start, children: [ new Text( - S.of(context).check_option_select_token(product.productAttributes[this.index].name), + S.of(context).check_option_select_token(product.productAttributes![this.index].name), style: new TextStyle( fontSize: 12.5, ), overflow: TextOverflow.ellipsis, ), new Text( - product.productAttributes[this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional, + product.productAttributes![this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional, style: new TextStyle( fontSize: 10.0, color: new Color(0xFF999999) @@ -86,33 +86,33 @@ class QtyOptionsState extends OptionsBaseState { 'adjust_amount': adjustAmount }; var cloneSelections = json.decode(json.encode(selections)); - int idx = Utils.selectionsContains(cloneSelections, product.productAttributes[index].name, name); + int idx = Utils.selectionsContains(cloneSelections, product.productAttributes![index].name, name); if (idx != -1) { if (quantity == 1) { - cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'] += 1; - optionsState[product.productAttributes[index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity']; + cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'] += 1; + optionsState[product.productAttributes![index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity']; } else { - if (cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'] - 1 > 0) { - cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'] -= 1; - optionsState[product.productAttributes[index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity']; + if (cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'] - 1 > 0) { + cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'] -= 1; + optionsState[product.productAttributes![index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity']; } else { - (cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).removeAt(idx); - optionsState[product.productAttributes[index].name][optIndex]['quantity'] = 0; + (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).removeAt(idx); + optionsState[product.productAttributes![index].name][optIndex]['quantity'] = 0; } } - } else if (cloneSelections.containsKey(product.productAttributes[index].name.toUpperCase())) { - (cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).add(opt); - optionsState[product.productAttributes[index].name][optIndex]['quantity'] = 1; + } else if (cloneSelections.containsKey(product.productAttributes![index].name!.toUpperCase())) { + (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).add(opt); + optionsState[product.productAttributes![index].name][optIndex]['quantity'] = 1; } else { - cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt]; - optionsState[product.productAttributes[index].name][optIndex]['quantity'] = 1; + cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt]; + optionsState[product.productAttributes![index].name][optIndex]['quantity'] = 1; } - if (idx != -1 && (cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).length == 0) { - cloneSelections.remove(product.productAttributes[index].name.toUpperCase()); + if (idx != -1 && (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).length == 0) { + cloneSelections.remove(product.productAttributes![index].name!.toUpperCase()); } - setOptionsStateDisabled(product.productAttributes[index].name, false); + setOptionsStateDisabled(product.productAttributes![index].name, false); setState(() { selections = cloneSelections; @@ -125,24 +125,24 @@ class QtyOptionsState extends OptionsBaseState { children: [], ); - List productOptions = product.productAttributes[index].productOptions; + List productOptions = product.productAttributes![index].productOptions; - if (!optionsState.containsKey(product.productAttributes[index].name)) { + if (!optionsState.containsKey(product.productAttributes![index].name)) { List> optionState = []; for (var i = 0; i < productOptions.length; i++) { int qty = 0; - int idx = Utils.selectionsContains(selections, product.productAttributes[index].name, productOptions[i].name); + int idx = Utils.selectionsContains(selections, product.productAttributes![index].name, productOptions[i].name); if (idx != -1) { - qty = selections[product.productAttributes[index].name.toUpperCase()][idx]['quantity']; + qty = selections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity']; } - optionState.add({'name': product.productAttributes[index].productOptions[i].name, 'disabled': false, 'quantity': qty, 'check': false}); + optionState.add({'name': product.productAttributes![index].productOptions![i].name, 'disabled': false, 'quantity': qty, 'check': false}); } - optionsState[product.productAttributes[index].name] = optionState; + optionsState[product.productAttributes![index].name] = optionState; } - if (selections.containsKey(product.productAttributes[index].name.toUpperCase())) { + if (selections.containsKey(product.productAttributes![index].name!.toUpperCase())) { Map attrExtraJson = Utils.stringToJson( - product.productAttributes[index].extra); + product.productAttributes![index].extra); if (attrExtraJson != null) { var selectLimitIfFieldEqualsTo = Rule.getRule( attrExtraJson, Rule.RULE_SELECT_LIMIT_IF_FIELD_EQUALS_TO); @@ -155,7 +155,7 @@ class QtyOptionsState extends OptionsBaseState { int limitQty = selectLimitIfFieldEqualsTo1[Rule .RULE_KEY_FORCE_LIMITED]; thisLimitQty = limitQty; - if ((selections[product.productAttributes[index].name + if ((selections[product.productAttributes![index].name .toUpperCase()] as List).length >= limitQty) { disableOptionIfNotSelected(); } @@ -163,7 +163,7 @@ class QtyOptionsState extends OptionsBaseState { if (selectLimitIfFieldEqualsTo1.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0])) { int limitQty = selectLimitIfFieldEqualsTo1[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0]]; thisLimitQty = limitQty; - if ((selections[product.productAttributes[index].name + if ((selections[product.productAttributes![index].name .toUpperCase()] as List).length >= limitQty) { disableOptionIfNotSelected(); } @@ -176,7 +176,7 @@ class QtyOptionsState extends OptionsBaseState { int limitQty = selectLimitIfFieldEqualsTo[Rule .RULE_KEY_FORCE_LIMITED]; thisLimitQty = limitQty; - if ((selections[product.productAttributes[index].name + if ((selections[product.productAttributes![index].name .toUpperCase()] as List).length >= limitQty) { disableOptionIfNotSelected(); } @@ -184,7 +184,7 @@ class QtyOptionsState extends OptionsBaseState { if (selectLimitIfFieldEqualsTo.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0])) { int limitQty = selectLimitIfFieldEqualsTo[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0]]; thisLimitQty = limitQty; - if ((selections[product.productAttributes[index].name + if ((selections[product.productAttributes![index].name .toUpperCase()] as List).length >= limitQty) { disableOptionIfNotSelected(); } @@ -203,12 +203,12 @@ class QtyOptionsState extends OptionsBaseState { Map multiItemRule = Rule.getRule(extraJson, Rule.RULE_ACTUAL_QTY_IS); if (exclusiveRule != null) { if (thisLimitQty > 0 && !_checkOptionIsCheck(productOptions[i].name)) { - optionsState[product.productAttributes[index].name][i]['disabled'] = true; + optionsState[product.productAttributes![index].name][i]['disabled'] = true; } else { if (_checkOptionIsCheck(productOptions[i].name)) { setOptionsStateDisabled( - product.productAttributes[index].name, true); - optionsState[product.productAttributes[index] + product.productAttributes![index].name, true); + optionsState[product.productAttributes![index] .name][i]['disabled'] = false; break; } @@ -216,12 +216,12 @@ class QtyOptionsState extends OptionsBaseState { } if (multiItemRule != null) { if (_checkOptionIsCheck(productOptions[i].name)) { - if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) { + if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes![index].name!.toUpperCase()] as List).length) { disableOptionIfNotSelected(); } } else { - if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) { - optionsState[product.productAttributes[index] + if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes![index].name!.toUpperCase()] as List).length) { + optionsState[product.productAttributes![index] .name][i]['disabled'] = true; } } @@ -230,26 +230,26 @@ class QtyOptionsState extends OptionsBaseState { } } - List> optionState = optionsState[product.productAttributes[index].name]; + List> optionState = optionsState[product.productAttributes![index].name]; for (var i = 0; i < optionState.length; i++) { Widget optionWidget = _getOptionQty( - product.productAttributes[index].productOptions[i], optionState[i]['disabled'], optionState[i]['quantity'], i); + product.productAttributes![index].productOptions![i], optionState[i]['disabled'], optionState[i]['quantity'], i); row.children.add(optionWidget); } return row; } void disableOptionIfNotSelected() { - setOptionsStateDisabled(product.productAttributes[index].name, true); - for (var i = 0; i < optionsState[product.productAttributes[index].name].length; i++) { - if (Utils.selectionsContains(selections, product.productAttributes[index].name, optionsState[product.productAttributes[index].name][i]['name']) != -1) { - optionsState[product.productAttributes[index].name][i]['disabled'] = false; + setOptionsStateDisabled(product.productAttributes![index].name, true); + for (var i = 0; i < optionsState[product.productAttributes![index].name].length; i++) { + if (Utils.selectionsContains(selections, product.productAttributes![index].name, optionsState[product.productAttributes![index].name][i]['name']) != -1) { + optionsState[product.productAttributes![index].name][i]['disabled'] = false; } } } bool _checkOptionIsCheck(String name) { - if (Utils.selectionsContains(selections, product.productAttributes[index].name, name) != -1) { + if (Utils.selectionsContains(selections, product.productAttributes![index].name, name) != -1) { return true; } return false; @@ -361,7 +361,7 @@ class QtyOptionsState extends OptionsBaseState { overflow: TextOverflow.ellipsis, ), new Text( - (productOption.adjustAmount + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount + extraAdjustAmount).toStringAsFixed(2)}' : '', + (productOption.adjustAmount! + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount! + extraAdjustAmount).toStringAsFixed(2)}' : '', style: new TextStyle( fontSize: 11.0, color: check ? selectedTextColor : new Color(0xFFABABAB), @@ -372,7 +372,7 @@ class QtyOptionsState extends OptionsBaseState { ), ), onTap: () => disabled ? null : _onOptionTappedCallback( - productOption.name, 1, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption), + productOption.name, 1, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption), ), new Container( width: 100.0, @@ -406,7 +406,7 @@ class QtyOptionsState extends OptionsBaseState { ), ), onTap: () => disabled ? null : _onOptionTappedCallback( - productOption.name, 1, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption), + productOption.name, 1, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption), ), ), new Expanded( @@ -420,7 +420,7 @@ class QtyOptionsState extends OptionsBaseState { ), ), onTap: () => (disabled || quantity == 0) ? null : _onOptionTappedCallback( - productOption.name, -1, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption), + productOption.name, -1, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption), ), ), ], diff --git a/lib/widgets/general/attribute/radio_options.dart b/lib/widgets/general/attribute/radio_options.dart index d05027e..ed89f19 100644 --- a/lib/widgets/general/attribute/radio_options.dart +++ b/lib/widgets/general/attribute/radio_options.dart @@ -40,14 +40,14 @@ class RadioOptionsState extends OptionsBaseState { crossAxisAlignment: CrossAxisAlignment.start, children: [ new Text( - S.of(context).radio_option_select_token(product.productAttributes[this.index].name), + S.of(context).radio_option_select_token(product.productAttributes![this.index].name), style: new TextStyle( fontSize: 12.5, ), overflow: TextOverflow.ellipsis, ), new Text( - product.productAttributes[this.index].required ? S.of(context).radio_option_is_required : S.of(context).radio_option_is_optional, + product.productAttributes![this.index].required ? S.of(context).radio_option_is_required : S.of(context).radio_option_is_optional, style: new TextStyle( fontSize: 10.0, color: new Color(0xFF999999) @@ -85,14 +85,14 @@ class RadioOptionsState extends OptionsBaseState { 'adjust_amount': adjustAmount }; var cloneSelections = json.decode(json.encode(selections)); - if (product.productAttributes[index].required) { - cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt]; + if (product.productAttributes![index].required) { + cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt]; } else { - if (cloneSelections.containsKey(product.productAttributes[index].name.toUpperCase()) - && Utils.equalsIgnoreCase(cloneSelections[product.productAttributes[index].name.toUpperCase()][0]['name'], name)) { - cloneSelections.remove(product.productAttributes[index].name.toUpperCase()); + if (cloneSelections.containsKey(product.productAttributes![index].name!.toUpperCase()) + && Utils.equalsIgnoreCase(cloneSelections[product.productAttributes![index].name!.toUpperCase()][0]['name'], name)) { + cloneSelections.remove(product.productAttributes![index].name!.toUpperCase()); } else { - cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt]; + cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt]; } } @@ -102,7 +102,7 @@ class RadioOptionsState extends OptionsBaseState { extraJson, Rule.RULE_EXCLUSIVE_SELECTION); if (exclusiveRule != null) { if (_checkOptionIsCheck(productOption.name)) { - setOptionsStateDisabled(product.productAttributes[index].name, false); + setOptionsStateDisabled(product.productAttributes![index].name, false); } } } @@ -118,14 +118,14 @@ class RadioOptionsState extends OptionsBaseState { children: [], ); - List productOptions = product.productAttributes[index].productOptions; + List productOptions = product.productAttributes![index].productOptions; - if (!optionsState.containsKey(product.productAttributes[index].name)) { + if (!optionsState.containsKey(product.productAttributes![index].name)) { List> optionState = []; for (var i = 0; i < productOptions.length; i++) { - optionState.add({'name': product.productAttributes[index].productOptions[i].name, 'disabled': false, 'check': false}); + optionState.add({'name': product.productAttributes![index].productOptions![i].name, 'disabled': false, 'check': false}); } - optionsState[product.productAttributes[index].name] = optionState; + optionsState[product.productAttributes![index].name] = optionState; } for (var i = 0; i < productOptions.length; i++) { @@ -135,25 +135,25 @@ class RadioOptionsState extends OptionsBaseState { extraJson, Rule.RULE_EXCLUSIVE_SELECTION); if (exclusiveRule != null) { if (_checkOptionIsCheck(productOptions[i].name)) { - setOptionsStateDisabled(product.productAttributes[index].name, true); - optionsState[product.productAttributes[index].name][i]['disabled'] = false; + setOptionsStateDisabled(product.productAttributes![index].name, true); + optionsState[product.productAttributes![index].name][i]['disabled'] = false; break; } } } } - List> optionState = optionsState[product.productAttributes[index].name]; + List> optionState = optionsState[product.productAttributes![index].name]; for (var i = 0; i < optionState.length; i++) { Widget optionWidget = _getOptionRadio( - product.productAttributes[index].productOptions[i], optionState[i]['disabled'], i); + product.productAttributes![index].productOptions![i], optionState[i]['disabled'], i); row.children.add(optionWidget); } return row; } bool _checkOptionIsCheck(String name) { - if (Utils.selectionsContains(selections, product.productAttributes[index].name, name) != -1) { + if (Utils.selectionsContains(selections, product.productAttributes![index].name, name) != -1) { return true; } return false; @@ -255,7 +255,7 @@ class RadioOptionsState extends OptionsBaseState { overflow: TextOverflow.ellipsis, ), new Text( - (productOption.adjustAmount + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount + extraAdjustAmount).toStringAsFixed(2)}' : '', + (productOption.adjustAmount! + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount! + extraAdjustAmount).toStringAsFixed(2)}' : '', style: new TextStyle( fontSize: 11.0, color: check ? selectedTextColor : new Color(0xFFABABAB), @@ -266,7 +266,7 @@ class RadioOptionsState extends OptionsBaseState { ), ), onTap: () => disabled ? null : _onOptionTappedCallback( - productOption.name, 0, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption), + productOption.name, 0, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption), ); } diff --git a/lib/widgets/general/carousel.dart b/lib/widgets/general/carousel.dart index e3572cc..23362a6 100644 --- a/lib/widgets/general/carousel.dart +++ b/lib/widgets/general/carousel.dart @@ -6,8 +6,8 @@ import 'style.dart'; class Carousel extends StatefulWidget { Carousel({ double height = 200.0, - List pages, - bool autoPlay, + List? pages, + bool? autoPlay, Duration duration = const Duration(seconds: 2), Duration animationDuration = const Duration(milliseconds: 1000), }) @@ -30,7 +30,7 @@ class Carousel extends StatefulWidget { class CarouselState extends State { final _pageController = new PageController(); - Timer _timer; + late Timer _timer; int _currentPage = 0; bool reverse = false; GlobalKey _indicatorStateKey = new GlobalKey(); @@ -80,7 +80,7 @@ class CarouselState extends State { children: widget.pages, onPageChanged: (index) { _currentPage = index; - _indicatorStateKey.currentState.changeIndex(index); + _indicatorStateKey.currentState!.changeIndex(index); }, ), ), @@ -102,7 +102,7 @@ class CarouselState extends State { } class Indicator extends StatefulWidget { - Indicator({Key? key, int count}) + Indicator({Key? key, int? count}) : count = count, super(key: key); diff --git a/lib/widgets/general/e_transfer_pay.dart b/lib/widgets/general/e_transfer_pay.dart index 18e7130..d2bae97 100644 --- a/lib/widgets/general/e_transfer_pay.dart +++ b/lib/widgets/general/e_transfer_pay.dart @@ -65,7 +65,7 @@ class ETransferPay extends StatelessWidget { fontSize: 15, color: Colors.black54), ), Text( - '\$${order.totalPrice.toStringAsFixed(2)}', + '\$${order.totalPrice!.toStringAsFixed(2)}', style: const TextStyle( fontSize: 28, fontWeight: FontWeight.bold, diff --git a/lib/widgets/general/parabolic_animation_widget.dart b/lib/widgets/general/parabolic_animation_widget.dart index 5aa0176..a2fa1f8 100644 --- a/lib/widgets/general/parabolic_animation_widget.dart +++ b/lib/widgets/general/parabolic_animation_widget.dart @@ -11,7 +11,7 @@ class ParabolicAnimationWidget extends AnimatedWidget { final Offset startAdjustOffset; final Offset endAdjustOffset; - ParabolicAnimationWidget({ + late ParabolicAnimationWidget({ @required Animation animation, @required this.stackKey, @required this.startKey, @@ -66,17 +66,17 @@ class ParabolicAnimationWidget extends AnimatedWidget { void _calPoints() { if (_startOffset == null) { - RenderBox stackBox = stackKey.currentContext.findRenderObject(); + RenderBox stackBox = stackKey.currentContext!.findRenderObject(); Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero); EdgeInsets startMargin = _margin(startKey); - RenderBox startBox = startKey.currentContext.findRenderObject(); + RenderBox startBox = startKey.currentContext!.findRenderObject(); _startOffset = startBox.localToGlobal(Offset( startMargin.left + startAdjustOffset.dx, stackBoxOffset.dy + startMargin.top + startAdjustOffset.dy)); EdgeInsets endMargin = _margin(endKey); - RenderBox endBox = endKey.currentContext.findRenderObject(); + RenderBox endBox = endKey.currentContext!.findRenderObject(); _endOffset = endBox.localToGlobal(Offset( endMargin.left + endAdjustOffset.dx, stackBoxOffset.dy + endMargin.top + endAdjustOffset.dy)); @@ -84,7 +84,7 @@ class ParabolicAnimationWidget extends AnimatedWidget { } EdgeInsets _margin(GlobalKey key) { - final Widget widget = key.currentContext.widget; + final Widget widget = key.currentContext!.widget; EdgeInsets margin = (widget is Container) ? widget.margin : EdgeInsets.zero; return margin ?? EdgeInsets.zero; } diff --git a/lib/widgets/general/payment_verification_code_dialog.dart b/lib/widgets/general/payment_verification_code_dialog.dart index 2d2fe52..c23d6d6 100644 --- a/lib/widgets/general/payment_verification_code_dialog.dart +++ b/lib/widgets/general/payment_verification_code_dialog.dart @@ -33,8 +33,8 @@ class PaymentVerificationCodeDialogState extends State animation; - PopupAnimationWidget({ + late PopupAnimationWidget({ @required this.animation, @required this.stackKey, @required this.startKey, @@ -49,11 +49,11 @@ class PopupAnimationWidget extends AnimatedWidget { void _calAnimation() { if (_startOffset == null) { - final RenderBox stackBox = stackKey.currentContext.findRenderObject(); + final RenderBox stackBox = stackKey.currentContext!.findRenderObject(); final Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero); final EdgeInsets startMargin = _margin(startKey); - final RenderBox startBox = startKey.currentContext.findRenderObject(); + final RenderBox startBox = startKey.currentContext!.findRenderObject(); _startOffset = startBox.localToGlobal(Offset( startMargin.left + popupOffset.dx, @@ -62,7 +62,7 @@ class PopupAnimationWidget extends AnimatedWidget { } EdgeInsets _margin(GlobalKey key) { - final Widget widget = key.currentContext.widget; + final Widget widget = key.currentContext!.widget; final EdgeInsets margin = (widget is Container) ? widget.margin : EdgeInsets.zero; return margin ?? EdgeInsets.zero; diff --git a/lib/widgets/general/sliding_up_panel.dart b/lib/widgets/general/sliding_up_panel.dart index 0cb67c5..c7311dc 100644 --- a/lib/widgets/general/sliding_up_panel.dart +++ b/lib/widgets/general/sliding_up_panel.dart @@ -211,9 +211,9 @@ class SlidingUpPanel extends StatefulWidget { class _SlidingUpPanelState extends State with SingleTickerProviderStateMixin{ - AnimationController _ac; + late AnimationController _ac; - ScrollController _sc; + late ScrollController _sc; bool _scrollingEnabled = false; VelocityTracker _vt = VelocityTracker.withKind(PointerDeviceKind.touch); @@ -390,7 +390,7 @@ class _SlidingUpPanelState extends State with SingleTickerProvid // and a listener if panelBuilder is used. // this is because the listener is designed only for use with linking the scrolling of // panels and using it for panels that don't want to linked scrolling yields odd results - Widget _gestureHandler({Widget child}){ + Widget _gestureHandler({Widget? child}){ if (!widget.isDraggable) return child; if (widget.panel != null){ @@ -552,14 +552,14 @@ class _SlidingUpPanelState extends State with SingleTickerProvid //animate the panel position to value - must //be between 0.0 and 1.0 - Future _animatePanelToPosition(double value, {Duration duration, Curve curve = Curves.linear}){ + Future _animatePanelToPosition(double value, {Duration? duration, Curve curve = Curves.linear}){ assert(0.0 <= value && value <= 1.0); return _ac.animateTo(value, duration: duration, curve: curve); } //animate the panel position to the snap point //REQUIRES that widget.snapPoint != null - Future _animatePanelToSnapPoint({Duration duration, Curve curve = Curves.linear}){ + Future _animatePanelToSnapPoint({Duration? duration, Curve curve = Curves.linear}){ assert(widget.snapPoint != null); return _ac.animateTo(widget.snapPoint, duration: duration, curve: curve); } @@ -602,7 +602,7 @@ class _SlidingUpPanelState extends State with SingleTickerProvid class PanelController{ - _SlidingUpPanelState _panelState; + late _SlidingUpPanelState _panelState; void _addState(_SlidingUpPanelState panelState){ this._panelState = panelState; @@ -644,7 +644,7 @@ class PanelController{ /// where 0.0 is fully collapsed and 1.0 is completely open. /// (optional) duration specifies the time for the animation to complete /// (optional) curve specifies the easing behavior of the animation. - Future animatePanelToPosition(double value, {Duration duration, Curve curve = Curves.linear}){ + Future animatePanelToPosition(double value, {Duration? duration, Curve curve = Curves.linear}){ assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); assert(0.0 <= value && value <= 1.0); return _panelState._animatePanelToPosition(value, duration: duration, curve: curve); @@ -654,7 +654,7 @@ class PanelController{ /// Requires that the SlidingUpPanel snapPoint property is not null /// (optional) duration specifies the time for the animation to complete /// (optional) curve specifies the easing behavior of the animation. - Future animatePanelToSnapPoint({Duration duration, Curve curve = Curves.linear}){ + Future animatePanelToSnapPoint({Duration? duration, Curve curve = Curves.linear}){ assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); assert(_panelState.widget.snapPoint != null, "SlidingUpPanel snapPoint property must not be null"); return _panelState._animatePanelToSnapPoint(duration: duration, curve: curve); diff --git a/lib/widgets/mobile/create_online_store_1.dart b/lib/widgets/mobile/create_online_store_1.dart index b6424d0..2e9e966 100644 --- a/lib/widgets/mobile/create_online_store_1.dart +++ b/lib/widgets/mobile/create_online_store_1.dart @@ -30,12 +30,12 @@ class CreateOnlineStore1State extends State { bool canSubmit = false; List stores = []; - Map service; + late Map service; dynamic selectedStore; - Group group; + late Group group; - String selectedDomain; + late String selectedDomain; List domainResult = []; @override @@ -231,7 +231,7 @@ class CreateOnlineStore1State extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).domains_separated_comma; } return null; diff --git a/lib/widgets/mobile/mobile_attribute_selection.dart b/lib/widgets/mobile/mobile_attribute_selection.dart index 0201559..608fe4a 100644 --- a/lib/widgets/mobile/mobile_attribute_selection.dart +++ b/lib/widgets/mobile/mobile_attribute_selection.dart @@ -33,18 +33,18 @@ class MobileAttributeSelection extends StatefulWidget { } class MobileAttributeSelectionState extends State { - 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 selections = new Map(); @@ -118,31 +118,31 @@ class MobileAttributeSelectionState extends State { 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 { 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 { 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 { } 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); } diff --git a/lib/widgets/mobile/mobile_blog.dart b/lib/widgets/mobile/mobile_blog.dart index 1f9558f..6e36504 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 { - List blogs; + late List blogs; int _page = 1; int _pageCount = 1; diff --git a/lib/widgets/mobile/mobile_buy_service.dart b/lib/widgets/mobile/mobile_buy_service.dart index cc0994b..3ab13e5 100644 --- a/lib/widgets/mobile/mobile_buy_service.dart +++ b/lib/widgets/mobile/mobile_buy_service.dart @@ -20,7 +20,7 @@ class MobileBuyService extends StatefulWidget { class MobileBuyServiceState extends State { List plans = []; - KeyValue selectedPlan; + late KeyValue selectedPlan; double price = 0.0; double tax = 0.0; double paymentAmount = 0.0; diff --git a/lib/widgets/mobile/mobile_change_mobile_or_email.dart b/lib/widgets/mobile/mobile_change_mobile_or_email.dart index 8423325..893ec13 100644 --- a/lib/widgets/mobile/mobile_change_mobile_or_email.dart +++ b/lib/widgets/mobile/mobile_change_mobile_or_email.dart @@ -31,9 +31,9 @@ class MobileChangeMobileOrEmailState extends State { bool usernameEnable = true; final codeController = TextEditingController(); - bool enableGetCode; - String getCodeText; - bool canRegister; + late bool enableGetCode; + late String getCodeText; + late bool canRegister; var countDownListener; @@ -94,7 +94,7 @@ class MobileChangeMobileOrEmailState extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { if (widget.isMobile) { return S .of(context) @@ -105,10 +105,10 @@ class MobileChangeMobileOrEmailState extends State { .email_is_required; } } - if (widget.isMobile && value.trim() == store.state.user.mobile) { + if (widget.isMobile && value!.trim() == store.state.user!.mobile) { return S.of(context).the_mobile_number_is_same_as_current; } - if (!widget.isMobile && value.trim() == store.state.user.email) { + if (!widget.isMobile && value!.trim() == store.state.user!.email) { return S.of(context).the_email_is_same_as_current; } return null; @@ -191,7 +191,7 @@ class MobileChangeMobileOrEmailState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).verification_code_is_required; } return null; @@ -269,7 +269,7 @@ class MobileChangeMobileOrEmailState extends State { }, isFormData: true, body: { - 'id': store.state.user.id, + 'id': store.state.user!.id, 'mobile': usernameController.text.trim(), 'code': codeController.text.trim(), }, @@ -281,8 +281,8 @@ class MobileChangeMobileOrEmailState extends State { void getCodeTapped() { if (usernameController.text.isNotEmpty && - ((widget.isMobile && usernameController.text.trim() != store.state.user.mobile) || - (!widget.isMobile && usernameController.text.trim() != store.state.user.email))) { + ((widget.isMobile && usernameController.text.trim() != store.state.user!.mobile) || + (!widget.isMobile && usernameController.text.trim() != store.state.user!.email))) { HttpUtil.httpPost('v1/users', (response) { Fluttertoast.showToast( msg: S.of(context).verification_code_sent, @@ -303,7 +303,7 @@ class MobileChangeMobileOrEmailState extends State { 'action': 'change_mobile_email_send_code' }, body: { - 'id': store.state.user.id, + 'id': store.state.user!.id, 'mobile': usernameController.text, }, isFormData: true, @@ -321,9 +321,9 @@ class MobileChangeMobileOrEmailState extends State { errorMsg = S.of(context).mobile_is_required; } else if (!widget.isMobile && usernameController.text.trim().isEmpty) { errorMsg = S.of(context).email_is_required; - } else if (widget.isMobile && usernameController.text.trim() == store.state.user.mobile) { + } else if (widget.isMobile && usernameController.text.trim() == store.state.user!.mobile) { errorMsg = S.of(context).the_mobile_number_is_same_as_current; - } else if (!widget.isMobile && usernameController.text.trim() == store.state.user.email) { + } else if (!widget.isMobile && usernameController.text.trim() == store.state.user!.email) { errorMsg = S.of(context).the_email_is_same_as_current; } Fluttertoast.showToast( diff --git a/lib/widgets/mobile/mobile_change_password.dart b/lib/widgets/mobile/mobile_change_password.dart index e892a74..07881b4 100644 --- a/lib/widgets/mobile/mobile_change_password.dart +++ b/lib/widgets/mobile/mobile_change_password.dart @@ -22,10 +22,10 @@ class MobileChangePasswordState extends State { final passwordController = TextEditingController(); final passwordAgainController = TextEditingController(); - bool passwordVisible; - bool passwordAgainVisible; + late bool passwordVisible; + late bool passwordAgainVisible; - bool canReset; + late bool canReset; @override void initState() { @@ -88,7 +88,7 @@ class MobileChangePasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).current_password_is_required; } return null; @@ -142,7 +142,7 @@ class MobileChangePasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } return null; @@ -196,10 +196,10 @@ class MobileChangePasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } - if (value.trim() != passwordController.text.trim()) { + if (value!.trim() != passwordController.text.trim()) { return S.of(context).password_is_not_match_password_again; } return null; @@ -276,7 +276,7 @@ class MobileChangePasswordState extends State { }, isFormData: true, body: { - 'id': store.state.user.id, + 'id': store.state.user!.id, 'old_password': oldPasswordController.text.trim(), 'password': passwordController.text.trim(), } diff --git a/lib/widgets/mobile/mobile_checkout.dart b/lib/widgets/mobile/mobile_checkout.dart index fdca378..5f59cfe 100644 --- a/lib/widgets/mobile/mobile_checkout.dart +++ b/lib/widgets/mobile/mobile_checkout.dart @@ -45,17 +45,17 @@ class MobileCheckout extends StatefulWidget { } class MobileCheckoutState extends State with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { - CartInfo cartInfo; - Address shipAddress; - bool canSubmit; - List errorMessages; - List bookingTimeList; - List bookingDateTimeList; - List paymentPlatforms; - TextValue durationInTraffic; - int selectedCoupon; + late CartInfo cartInfo; + late Address shipAddress; + late bool canSubmit; + late List errorMessages; + late List bookingTimeList; + late List bookingDateTimeList; + late List paymentPlatforms; + late TextValue durationInTraffic; + late int selectedCoupon; double couponDiscountAmount = 0; - List coupons; + late List coupons; int peopleCount = 2; @@ -63,25 +63,25 @@ class MobileCheckoutState extends State with SingleTickerProvide String orderRemark = ''; int deliveryMethodIndex = 0; - String deliveryMethod; + late String deliveryMethod; List shippingRates = []; - ShippingRate selectedShippingRate; + late ShippingRate selectedShippingRate; List shippingMethodLabels = []; List shippingMethodIcons = []; GlobalKey _scaffoldKey = GlobalKey(); - int bookingDateIndex; - int bookingTimeIndex; - int paymentPlatformIndex; + late int bookingDateIndex; + late int bookingTimeIndex; + late int paymentPlatformIndex; GlobalKey slidingUpPanelKey = GlobalKey(); - SlidingUpPanel slidingUpPanel; + late SlidingUpPanel slidingUpPanel; PanelController panelController = PanelController(); - Widget panel; + late Widget panel; - double subtotal; + late double subtotal; TextEditingController newCouponController = TextEditingController(); @@ -102,7 +102,7 @@ class MobileCheckoutState extends State with SingleTickerProvide ); } - if (cartInfo.businessInfo.deliveryPickup == false && cartInfo.businessInfo.deliveryCanadaPost == false && cartInfo.businessInfo.deliveryStoreDelivery == false) { + if (cartInfo.businessInfo!.deliveryPickup == false && cartInfo.businessInfo!.deliveryCanadaPost == false && cartInfo.businessInfo!.deliveryStoreDelivery == false) { return Scaffold( body: Container( child: Center( @@ -197,13 +197,13 @@ class MobileCheckoutState extends State with SingleTickerProvide mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - '\$${(cartInfo.totalPrice - couponDiscountAmount).toStringAsFixed(2)}', + '\$${(cartInfo.totalPrice! - couponDiscountAmount).toStringAsFixed(2)}', style: TextStyle( fontSize: 20.0, color: Colors.white, ), ), - cartInfo.businessInfo.isPublic ? SizedBox.shrink() : Container( + cartInfo.businessInfo!.isPublic ? SizedBox.shrink() : Container( padding: EdgeInsets.only(top: 2.0, bottom: 2.0, left: 5.0, right: 5.0), width: 100.0, color: Colors.red, @@ -267,7 +267,7 @@ class MobileCheckoutState extends State with SingleTickerProvide itemCount: 6, addAutomaticKeepAlives: true, itemBuilder: (BuildContext context, int position) { - var deliveryTimeInSeconds = cartInfo.businessInfo.shippingTime * 60 + (durationInTraffic != null ? durationInTraffic.value : 0); + var deliveryTimeInSeconds = cartInfo.businessInfo!.shippingTime! * 60 + (durationInTraffic != null ? durationInTraffic.value : 0); print('aaa: $deliveryTimeInSeconds'); DateTime now = DateTime.now(); var formatter = DateFormat('H:mm'); @@ -341,7 +341,7 @@ class MobileCheckoutState extends State with SingleTickerProvide ); switch (position) { case 0: - if (cartInfo.businessInfo.deliveryPickup) { + if (cartInfo.businessInfo!.deliveryPickup) { return Container( padding: EdgeInsets.only( top: 16.0, bottom: 16.0, left: 16.0, right: 16.0), @@ -355,8 +355,8 @@ class MobileCheckoutState extends State with SingleTickerProvide ), child: Container( alignment: Alignment.centerLeft, - child: store.state.deviceId != null && store.state.deviceId.isNotEmpty ? ( - store.state.tableNumber != null && store.state.tableNumber.isNotEmpty ? + child: store.state.deviceId != null && store.state.deviceId!.isNotEmpty ? ( + store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty ? peopleCountSelection : SizedBox.shrink() ) : Center(child: toggleSwitch,), @@ -369,8 +369,8 @@ class MobileCheckoutState extends State with SingleTickerProvide } break; case 1: - if (store.state.deviceId != null && store.state.deviceId.isNotEmpty || - store.state.tableNumber != null && store.state.tableNumber.isNotEmpty) { + if (store.state.deviceId != null && store.state.deviceId!.isNotEmpty || + store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty) { return SizedBox.shrink(); } if (deliveryMethod == 'pickup') { @@ -389,7 +389,7 @@ class MobileCheckoutState extends State with SingleTickerProvide Container( margin: EdgeInsets.only(top: 10.0), child: Text( - cartInfo.businessInfo.name, + cartInfo.businessInfo!.name, style: TextStyle( fontSize: 17.0, ), @@ -398,7 +398,7 @@ class MobileCheckoutState extends State with SingleTickerProvide Container( margin: EdgeInsets.only(top: 5.0), child: Text( - cartInfo.businessInfo.address.addressLine1, + cartInfo.businessInfo!.address!.addressLine1, style: TextStyle( fontSize: 14.0, color: Colors.black45, @@ -406,9 +406,9 @@ class MobileCheckoutState extends State with SingleTickerProvide ), ), Container( - child: cartInfo.businessInfo.address.addressLine2 != null - && cartInfo.businessInfo.address.addressLine2.length > 0 ? - Text(cartInfo.businessInfo.address.addressLine2, + child: cartInfo.businessInfo!.address!.addressLine2 != null + && cartInfo.businessInfo!.address!.addressLine2!.length > 0 ? + Text(cartInfo.businessInfo!.address!.addressLine2, style: TextStyle( fontSize: 14.0, color: Colors.black45, @@ -417,7 +417,7 @@ class MobileCheckoutState extends State with SingleTickerProvide ), Container( child: Text( - '${cartInfo.businessInfo.address.city}, ${cartInfo.businessInfo.address.state}, ${cartInfo.businessInfo.address.zip}', + '${cartInfo.businessInfo!.address!.city}, ${cartInfo.businessInfo!.address!.state}, ${cartInfo.businessInfo!.address!.zip}', style: TextStyle( fontSize: 14.0, color: Colors.black45, @@ -427,7 +427,7 @@ class MobileCheckoutState extends State with SingleTickerProvide Container( margin: EdgeInsets.only(top: 5.0), child: Text( - 'Tel: ${cartInfo.businessInfo.phone}', + 'Tel: ${cartInfo.businessInfo!.phone}', style: TextStyle( fontSize: 15.0, color: Colors.black54, @@ -480,7 +480,7 @@ class MobileCheckoutState extends State with SingleTickerProvide Container( padding: EdgeInsets.only(top: 6.0), child: Text( - shipAddress != null ? shipAddress.contactName + ' ' + shipAddress.phone : '', + shipAddress != null ? shipAddress.contactName! + ' ' + shipAddress.phone : '', style: TextStyle( fontSize: 14.0, color: Colors.black38, @@ -504,13 +504,13 @@ class MobileCheckoutState extends State with SingleTickerProvide ), ), onTap: () { - Routes.router.navigateTo(context, '/my-addresses/${cartInfo.businessInfo.id}', replace: true); + Routes.router.navigateTo(context, '/my-addresses/${cartInfo.businessInfo!.id}', replace: true); }, ); break; case 2: - if (deliveryMethod == 'pickup' || store.state.deviceId != null && store.state.deviceId.isNotEmpty || - store.state.tableNumber != null && store.state.tableNumber.isNotEmpty) { + if (deliveryMethod == 'pickup' || store.state.deviceId != null && store.state.deviceId!.isNotEmpty || + store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty) { return SizedBox.shrink(); } if (deliveryMethod == 'canada-post') { @@ -553,7 +553,7 @@ class MobileCheckoutState extends State with SingleTickerProvide alignment: Alignment.centerRight, child: Text( selectedShippingRate != null ? - '${selectedShippingRate.name} \$${selectedShippingRate.price.toStringAsFixed(2)}' : + '${selectedShippingRate.name} \$${selectedShippingRate.price!.toStringAsFixed(2)}' : S.of(context).please_select, style: TextStyle( fontSize: 15.0, @@ -583,7 +583,7 @@ class MobileCheckoutState extends State with SingleTickerProvide }, ); } - if (!cartInfo.businessInfo.instanceDelivery) { + if (!cartInfo.businessInfo!.instanceDelivery) { return Container( padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 0.0, bottom: 16.0), child: Text(S.of(context).no_instance_delivery_desc), @@ -629,7 +629,7 @@ class MobileCheckoutState extends State with SingleTickerProvide child: Text( bookingTimeList.length > 0 ? '${Utils.timestampToString(context, bookingTimeList[bookingTimeIndex].unixTime)}' : ((bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ? '' - : bookingDateTimeList[bookingDateIndex].viewDate + ' ' + (bookingDateTimeList[bookingDateIndex].bookTimes.length > 0 ? bookingDateTimeList[bookingDateIndex].bookTimes[bookingTimeIndex].viewTime : '')), + : bookingDateTimeList[bookingDateIndex].viewDate! + ' ' + (bookingDateTimeList[bookingDateIndex].bookTimes!.length > 0 ? bookingDateTimeList[bookingDateIndex].bookTimes![bookingTimeIndex].viewTime : '')), ), ), Container( @@ -712,7 +712,7 @@ class MobileCheckoutState extends State with SingleTickerProvide width: double.infinity, padding: EdgeInsets.only(bottom: 10.0), child: Text( - cartInfo.businessInfo.name, + cartInfo.businessInfo!.name, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 16.0, @@ -731,9 +731,9 @@ class MobileCheckoutState extends State with SingleTickerProvide subtotal = 0.0; - for (var i = 0; i < cartInfo.productList.length; i++) { - subtotal += cartInfo.productList[i].totalPrice; - column.children.add(lineItem(cartInfo.productList[i])); + for (var i = 0; i < cartInfo.productList!.length; i++) { + subtotal += cartInfo.productList![i].totalPrice; + column.children.add(lineItem(cartInfo.productList![i])); } column.children.add(GestureDetector( child: Container( @@ -826,8 +826,8 @@ class MobileCheckoutState extends State with SingleTickerProvide ), )); - if (cartInfo.extraFeeList.length > 0) { - for (var i = 0; i < cartInfo.extraFeeList.length; i++) { + if (cartInfo.extraFeeList!.length > 0) { + for (var i = 0; i < cartInfo.extraFeeList!.length; i++) { column.children.add(Container( padding: EdgeInsets.only(bottom: 16.0), alignment: Alignment.centerRight, @@ -838,7 +838,7 @@ class MobileCheckoutState extends State with SingleTickerProvide Container( alignment: Alignment.centerRight, child: Text( - S.of(context).extra_fee_token(cartInfo.extraFeeList[i].name, cartInfo.extraFeeList[i].rate), + S.of(context).extra_fee_token(cartInfo.extraFeeList![i].name, cartInfo.extraFeeList![i].rate), style: TextStyle( color: Colors.grey, ), @@ -848,7 +848,7 @@ class MobileCheckoutState extends State with SingleTickerProvide width: 100.0, alignment: Alignment.centerRight, child: Text( - '${cartInfo.extraFeeList[i].price.toStringAsFixed(2)}' + '${cartInfo.extraFeeList![i].price!.toStringAsFixed(2)}' ), ), ], @@ -876,7 +876,7 @@ class MobileCheckoutState extends State with SingleTickerProvide width: 100.0, alignment: Alignment.centerRight, child: Text( - '${(cartInfo.totalPrice - couponDiscountAmount).toStringAsFixed(2)}', + '${(cartInfo.totalPrice! - couponDiscountAmount).toStringAsFixed(2)}', style: TextStyle( fontSize: 19.0, fontWeight: FontWeight.bold, @@ -974,7 +974,7 @@ class MobileCheckoutState extends State with SingleTickerProvide children: [ Container( padding: EdgeInsets.all(5.0), - child: Util.showImage('${cartLineItem.product.imagePath}', + child: Util.showImage('${cartLineItem.product!.imagePath}', width: 40.0, height: 40.0, fit: BoxFit.fill, @@ -1011,14 +1011,14 @@ class MobileCheckoutState extends State with SingleTickerProvide alignment: Alignment.centerRight, margin: EdgeInsets.only(right: 10.0), child: Text( - 'x${cartLineItem.quantity.round()}', + 'x${cartLineItem.quantity!.round()}', ), ), Container( width: 60.0, alignment: Alignment.centerRight, child: Text( - '${cartLineItem.totalPrice.toStringAsFixed(2)}', + '${cartLineItem.totalPrice!.toStringAsFixed(2)}', ), ), ], @@ -1074,7 +1074,7 @@ class MobileCheckoutState extends State with SingleTickerProvide shippingRates = (response.data['shipping_rates'] as List).map((e) => ShippingRate.fromJson(e)).toList(); selectedShippingRate = (response.data['selected_shipping_rate'] as String).length > 0 ? ShippingRate.fromJson(json.decode(response.data['selected_shipping_rate'])) : null; int i = 0; - if (cartInfo.businessInfo.deliveryStoreDelivery) { + if (cartInfo.businessInfo!.deliveryStoreDelivery) { shippingMethodLabels.add(S.of(context).delivery); shippingMethodIcons.add(Icons.directions_car); if (deliveryMethod == 'store-delivery') { @@ -1082,7 +1082,7 @@ class MobileCheckoutState extends State with SingleTickerProvide } i++; } - if (cartInfo.businessInfo.deliveryCanadaPost) { + if (cartInfo.businessInfo!.deliveryCanadaPost) { shippingMethodLabels.add(S.of(context).canada_post); shippingMethodIcons.add(Icons.local_shipping); if (deliveryMethod == 'canada-post') { @@ -1090,7 +1090,7 @@ class MobileCheckoutState extends State with SingleTickerProvide } i++; } - if (cartInfo.businessInfo.deliveryPickup) { + if (cartInfo.businessInfo!.deliveryPickup) { shippingMethodLabels.add(S.of(context).pickup); shippingMethodIcons.add(Icons.store); if (deliveryMethod == 'pickup') { @@ -1310,14 +1310,14 @@ class MobileCheckoutState extends State with SingleTickerProvide Expanded( child: SizedBox.expand( child: ListView.builder( - itemCount: bookingDateTimeList[bookingDateIndex].bookTimes.length, + itemCount: bookingDateTimeList[bookingDateIndex].bookTimes!.length, itemBuilder: (BuildContext context, int position) { BookingDateTime bookingDateTime = bookingDateTimeList[bookingDateIndex]; return GestureDetector( child: Container( padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0, bottom: 12.0), child: Text( - bookingDateTime.bookTimes[position].viewTime, + bookingDateTime.bookTimes![position].viewTime, ), decoration: BoxDecoration( border: Border( @@ -1442,16 +1442,16 @@ class MobileCheckoutState extends State with SingleTickerProvide itemBuilder: (BuildContext context, int position) { PaymentPlatform paymentPlatform = paymentPlatforms[position]; if (paymentPlatform.code == Constants.PAYMENT_METHOD_CODE_SQUARE && - (paymentPlatform.squareAppId == null || paymentPlatform.squareAppId.isEmpty) && - (paymentPlatform.squareAccessToken == null || paymentPlatform.squareAccessToken.isEmpty) && - (paymentPlatform.squareLocationId == null || paymentPlatform.squareLocationId.isEmpty) + (paymentPlatform.squareAppId == null || paymentPlatform.squareAppId!.isEmpty) && + (paymentPlatform.squareAccessToken == null || paymentPlatform.squareAccessToken!.isEmpty) && + (paymentPlatform.squareLocationId == null || paymentPlatform.squareLocationId!.isEmpty) ) { return SizedBox.shrink(); } if (paymentPlatform.code == Constants.PAYMENT_METHOD_CODE_CHASE && - (paymentPlatform.xLogin == null || paymentPlatform.xLogin.isEmpty) && - (paymentPlatform.transactionKey == null || paymentPlatform.transactionKey.isEmpty) && - (paymentPlatform.responseKey == null || paymentPlatform.responseKey.isEmpty) + (paymentPlatform.xLogin == null || paymentPlatform.xLogin!.isEmpty) && + (paymentPlatform.transactionKey == null || paymentPlatform.transactionKey!.isEmpty) && + (paymentPlatform.responseKey == null || paymentPlatform.responseKey!.isEmpty) ) { return SizedBox.shrink(); } @@ -1681,7 +1681,7 @@ class MobileCheckoutState extends State with SingleTickerProvide return GestureDetector( child: Container( decoration: selectedCoupon == 0 ? BoxDecoration( - color: subtotal > cartInfo.businessInfo.minPrice ? Colors + color: subtotal > cartInfo.businessInfo!.minPrice ? Colors .transparent : Colors.black38, border: Border( top: BorderSide( @@ -1702,7 +1702,7 @@ class MobileCheckoutState extends State with SingleTickerProvide ), ), ) : BoxDecoration( - color: subtotal > cartInfo.businessInfo.minPrice ? Colors + color: subtotal > cartInfo.businessInfo!.minPrice ? Colors .transparent : Colors.black38, ), child: Row( @@ -1743,7 +1743,7 @@ class MobileCheckoutState extends State with SingleTickerProvide return GestureDetector( child: Container( decoration: selectedCoupon == coupon.id ? BoxDecoration( - color: subtotal > cartInfo.businessInfo.minPrice ? Colors + color: subtotal > cartInfo.businessInfo!.minPrice ? Colors .transparent : Colors.black38, border: Border( top: BorderSide( @@ -1857,7 +1857,7 @@ class MobileCheckoutState extends State with SingleTickerProvide ), Container( child: Text( - coupon.minAmount > 0 ? + coupon.minAmount! > 0 ? S.of(context).min_order_amount_token( coupon.minAmount) : S.of(context) @@ -1917,7 +1917,7 @@ class MobileCheckoutState extends State with SingleTickerProvide crossAxisAlignment: CrossAxisAlignment.start, children: [], ); - if (cartInfo.businessInfo.quickInputs.length > 0) { + if (cartInfo.businessInfo!.quickInputs!.length > 0) { Wrap w = Wrap( children: [], ); @@ -1931,8 +1931,8 @@ class MobileCheckoutState extends State with SingleTickerProvide ), ), )); - for (int i = 0; i < cartInfo.businessInfo.quickInputs.length; i++) { - String qi = cartInfo.businessInfo.quickInputs[i].value; + for (int i = 0; i < cartInfo.businessInfo!.quickInputs!.length; i++) { + String qi = cartInfo.businessInfo!.quickInputs![i].value; w.children.add(TextButton( child: Text( qi, @@ -2112,7 +2112,7 @@ class MobileCheckoutState extends State with SingleTickerProvide child: Container( alignment: Alignment.centerRight, child: Text( - '${shippingRate.price.toStringAsFixed(2)}', + '${shippingRate.price!.toStringAsFixed(2)}', style: TextStyle( fontSize: 16.0, color: Colors.black38, @@ -2203,7 +2203,7 @@ class MobileCheckoutState extends State with SingleTickerProvide : ( (bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ? 0 : - bookingDateTimeList[bookingDateIndex].bookTimes[bookingTimeIndex] + bookingDateTimeList[bookingDateIndex].bookTimes![bookingTimeIndex] .unixTime ), 'delivery': deliveryMethod, diff --git a/lib/widgets/mobile/mobile_contact_us.dart b/lib/widgets/mobile/mobile_contact_us.dart index 0f3d5e3..395cf73 100644 --- a/lib/widgets/mobile/mobile_contact_us.dart +++ b/lib/widgets/mobile/mobile_contact_us.dart @@ -29,7 +29,7 @@ class MobileContactUsState extends State { String mapUrl = 'https://goo.gl/maps/M365MF5AW35n9ij67'; Completer _controller = Completer(); - LatLng _lastMapPosition; + late LatLng _lastMapPosition; final Set _markers = {}; final Set _polyLine = {}; @@ -239,16 +239,16 @@ class MobileContactUsState extends State { Container( padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), child: Text( - '${widget.business.address.addressLine1}', + '${widget.business.address!.addressLine1}', ), ) ); - if (widget.business.address.addressLine2 != null && widget.business.address.addressLine2.isNotEmpty) { + if (widget.business.address!.addressLine2 != null && widget.business.address!.addressLine2!.isNotEmpty) { col.children.add( Container( padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), child: Text( - '${widget.business.address.addressLine2}', + '${widget.business.address!.addressLine2}', ), ) ); @@ -257,7 +257,7 @@ class MobileContactUsState extends State { Container( padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), child: Text( - '${widget.business.address.city}, ${widget.business.address.state}', + '${widget.business.address!.city}, ${widget.business.address!.state}', ), ) ); @@ -265,7 +265,7 @@ class MobileContactUsState extends State { Container( padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), child: Text( - '${widget.business.address.country}, ${widget.business.address.zip}', + '${widget.business.address!.country}, ${widget.business.address!.zip}', ), ) ); @@ -273,8 +273,8 @@ class MobileContactUsState extends State { _markers.clear(); _markers.add(Marker( markerId: MarkerId('shop_position'), - position: LatLng(double.parse(widget.business.address.lat), - double.parse(widget.business.address.lng)), + position: LatLng(double.parse(widget.business.address!.lat), + double.parse(widget.business.address!.lng)), infoWindow: InfoWindow( title: S .of(context) @@ -290,8 +290,8 @@ class MobileContactUsState extends State { onMapCreated: _onMapCreated, initialCameraPosition: CameraPosition( target: LatLng( - double.parse(widget.business.address.lat), - double.parse(widget.business.address.lng)), + double.parse(widget.business.address!.lat), + double.parse(widget.business.address!.lng)), zoom: 14.0, ), onCameraMove: _onCameraMove, diff --git a/lib/widgets/mobile/mobile_coupons.dart b/lib/widgets/mobile/mobile_coupons.dart index 1016eaf..c6485e8 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 { - List coupons; + late List coupons; @override Widget build(BuildContext context) { @@ -97,7 +97,7 @@ class MobileCouponsState extends State { Container( padding: EdgeInsets.only(right: 5.0), child: coupon.store != null ? - Util.showImage('${coupon.store.picUrl}', + Util.showImage('${coupon.store!.picUrl}', fit: BoxFit.fill, width: 40.0, ) : @@ -114,7 +114,7 @@ class MobileCouponsState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - coupon.store != null ? coupon.store.name : S.of(context).general_coupon, + coupon.store != null ? coupon.store!.name : S.of(context).general_coupon, style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, @@ -198,7 +198,7 @@ class MobileCouponsState extends State { ), Container( child: Text( - coupon.minAmount > 0 ? + coupon.minAmount! > 0 ? S.of(context).available_for_order_over_token(coupon.minAmount) : S.of(context).no_restriction, style: TextStyle( @@ -236,7 +236,7 @@ class MobileCouponsState extends State { children: [ Container( child: Text( - coupon.expirationDate == null || coupon.expirationDate.length == 0 ? + coupon.expirationDate == null || coupon.expirationDate!.length == 0 ? S.of(context).no_expiration : S.of(context).expiration_date_token(coupon.expirationDate), style: TextStyle( @@ -261,7 +261,7 @@ class MobileCouponsState extends State { ), onPressed: () { if (coupon.store != null) { - Routes.router.navigateTo(context, '/shop/${coupon.store.id}/na/na/na'); + Routes.router.navigateTo(context, '/shop/${coupon.store!.id}/na/na/na'); } else { Routes.router.navigateTo(context, '/businesses'); } diff --git a/lib/widgets/mobile/mobile_edit_address.dart b/lib/widgets/mobile/mobile_edit_address.dart index ab32977..eb8467f 100644 --- a/lib/widgets/mobile/mobile_edit_address.dart +++ b/lib/widgets/mobile/mobile_edit_address.dart @@ -43,12 +43,12 @@ class MobileEditAddressState extends State { final emailController = TextEditingController(); final faxController = TextEditingController(); - String country; - Gender _selectedGender; + late String country; + late Gender _selectedGender; - String _selectedProvince; + late String _selectedProvince; - bool showLoading; + late bool showLoading; @override Widget build(BuildContext context) { @@ -366,7 +366,7 @@ class MobileEditAddressState extends State { .email, ), validator: (String? value) { - if (value.isNotEmpty && !EmailValidator.validate(value)) { + if (value!.isNotEmpty && !EmailValidator.validate(value)) { return S .of(context) .email_is_not_valid; diff --git a/lib/widgets/mobile/mobile_forgot_password.dart b/lib/widgets/mobile/mobile_forgot_password.dart index 3d295d1..db2f464 100644 --- a/lib/widgets/mobile/mobile_forgot_password.dart +++ b/lib/widgets/mobile/mobile_forgot_password.dart @@ -28,9 +28,9 @@ class MobileForgotPasswordState extends State { bool usernameEnable = true; final codeController = TextEditingController(); - bool enableGetCode; - String getCodeText; - bool canRegister; + late bool enableGetCode; + late String getCodeText; + late bool canRegister; var countDownListener; @@ -91,7 +91,7 @@ class MobileForgotPasswordState extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).mobile_or_email_is_required; } return null; @@ -174,7 +174,7 @@ class MobileForgotPasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).verification_code_is_required; } return null; diff --git a/lib/widgets/mobile/mobile_login.dart b/lib/widgets/mobile/mobile_login.dart index bf94a37..df92a21 100644 --- a/lib/widgets/mobile/mobile_login.dart +++ b/lib/widgets/mobile/mobile_login.dart @@ -26,9 +26,9 @@ class MobileLoginState extends State { final usernameController = TextEditingController(); final passwordController = TextEditingController(); - bool passwordVisible; + late bool passwordVisible; - bool onSubmitting; + late bool onSubmitting; @override void initState() { @@ -104,7 +104,7 @@ class MobileLoginState extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).this_field_is_required; } return null; @@ -144,7 +144,7 @@ class MobileLoginState extends State { ), obscureText: passwordVisible, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } return null; diff --git a/lib/widgets/mobile/mobile_me.dart b/lib/widgets/mobile/mobile_me.dart index 4bbb679..f6da143 100644 --- a/lib/widgets/mobile/mobile_me.dart +++ b/lib/widgets/mobile/mobile_me.dart @@ -20,9 +20,9 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dart'; import '../../utils/utils.dart'; -MediaQueryData mediaQuery; -double statusBarHeight; -double screenHeight; +late MediaQueryData mediaQuery; +late double statusBarHeight; +late double screenHeight; class MobileMe extends StatefulWidget { final Key? key; @@ -36,18 +36,18 @@ class MobileMe extends StatefulWidget { } class MobileMeState extends State { - int userId; - String accessToken; + late int userId; + late String accessToken; - bool isLoading; - User _user; + late bool isLoading; + late User _user; - ShopScrollCoordinator _shopCoordinator; - ShopScrollController _pageScrollController; + late ShopScrollCoordinator _shopCoordinator; + late ShopScrollController _pageScrollController; final double _sliverAppBarInitHeight = 165.0; final double _appBarHeight = 85.0; - ShopScrollController _listScrollController1; + late ShopScrollController _listScrollController1; @override Widget build(BuildContext context) { @@ -88,7 +88,7 @@ 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}', width: 60, @@ -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, @@ -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 8c9795b..4e5b7c1 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 { - List
addresses; + late List
addresses; @override Widget build(BuildContext context) { diff --git a/lib/widgets/mobile/mobile_my_support.dart b/lib/widgets/mobile/mobile_my_support.dart index 86cfca1..3cf57b5 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 { - List tickets; + late List tickets; int _page = 1; int _pageCount = 1; @@ -179,7 +179,7 @@ class MobileMySupportState extends State { children: [ Container( child: Text( - ticket.issue.msg, + ticket.issue!.msg, style: TextStyle( fontSize: 19.0, ), @@ -208,7 +208,7 @@ class MobileMySupportState extends State { ) : SizedBox.shrink(), Text( - S.of(context).followups_token(ticket.followUps.length), + S.of(context).followups_token(ticket.followUps!.length), style: TextStyle( fontSize: 15.0, color: Colors.black87, diff --git a/lib/widgets/mobile/mobile_new_address.dart b/lib/widgets/mobile/mobile_new_address.dart index c1a7d14..887587e 100644 --- a/lib/widgets/mobile/mobile_new_address.dart +++ b/lib/widgets/mobile/mobile_new_address.dart @@ -36,9 +36,9 @@ class MobileNewAddressState extends State { final faxController = TextEditingController(); String country = 'CA'; - Gender _selectedGender; + late Gender _selectedGender; - String _selectedProvince; + late String _selectedProvince; List provinces = [ 'Ontario', @@ -97,7 +97,7 @@ class MobileNewAddressState extends State { labelText: S.of(context).contact_name, ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).contact_name_is_required; } return null; @@ -141,7 +141,7 @@ class MobileNewAddressState extends State { labelText: S.of(context).mobile_phone_number, ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).mobile_phone_number_is_required; } return null; @@ -166,7 +166,7 @@ class MobileNewAddressState extends State { labelText: S.of(context).street_line_1, ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).street_line_1_is_required; } return null; @@ -210,7 +210,7 @@ class MobileNewAddressState extends State { labelText: S.of(context).city, ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).city_is_required; } return null; @@ -256,7 +256,7 @@ class MobileNewAddressState extends State { labelText: S.of(context).postal_code, ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).postal_code_is_required; } return null; @@ -291,7 +291,7 @@ class MobileNewAddressState extends State { labelText: S.of(context).email, ), validator: (String? value) { - if (value.isNotEmpty && !EmailValidator.validate(value)) { + if (value!.isNotEmpty && !EmailValidator.validate(value)) { return S.of(context).email_is_not_valid; } return null; @@ -354,8 +354,8 @@ class MobileNewAddressState extends State { cityController.text = widget.locatedAddress.city; postalCodeController.text = widget.locatedAddress.postalCode; streetLine1Controller.text = (widget.locatedAddress.streetNumber != null - && widget.locatedAddress.streetNumber.isNotEmpty - ? widget.locatedAddress.streetNumber + ' ' : '') + && widget.locatedAddress.streetNumber!.isNotEmpty + ? widget.locatedAddress.streetNumber! + ' ' : '') + widget.locatedAddress.streetName; } else { _selectedProvince = 'Ontario'; diff --git a/lib/widgets/mobile/mobile_new_comment.dart b/lib/widgets/mobile/mobile_new_comment.dart index cb1a432..1c8beeb 100644 --- a/lib/widgets/mobile/mobile_new_comment.dart +++ b/lib/widgets/mobile/mobile_new_comment.dart @@ -31,13 +31,13 @@ class MobileNewComment extends StatefulWidget { } class MobileNewCommentState extends State { - Comment comment; + late Comment comment; - bool _showProgress; + late bool _showProgress; - double _progress; + late double _progress; - double rating; + late double rating; bool isSubmitting = false; @@ -167,7 +167,7 @@ class MobileNewCommentState extends State { children: [], ); - if (comment != null && comment.images.length > 0) { + if (comment != null && comment.images!.length > 0) { for (ProductImage image in comment.images) { row.children.add( Container( @@ -239,7 +239,7 @@ class MobileNewCommentState extends State { child: Icon( Icons.add, size: 60.0, - color: comment == null || comment.images.length < 3 ? Colors.lightBlue : Colors.black12, + color: comment == null || comment.images!.length < 3 ? Colors.lightBlue : Colors.black12, ), decoration: BoxDecoration( color: Colors.white70, @@ -264,7 +264,7 @@ class MobileNewCommentState extends State { ), ), onTap: () { - if (comment == null || comment.images.length < 3) { + if (comment == null || comment.images!.length < 3) { showDialog( context: mainContext, barrierDismissible: true, diff --git a/lib/widgets/mobile/mobile_new_ticket.dart b/lib/widgets/mobile/mobile_new_ticket.dart index 75e5d31..0840206 100644 --- a/lib/widgets/mobile/mobile_new_ticket.dart +++ b/lib/widgets/mobile/mobile_new_ticket.dart @@ -111,7 +111,7 @@ class MobileNewTicketState extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).this_field_is_required; } return null; diff --git a/lib/widgets/mobile/mobile_new_user.dart b/lib/widgets/mobile/mobile_new_user.dart index d4af700..4d0c68b 100644 --- a/lib/widgets/mobile/mobile_new_user.dart +++ b/lib/widgets/mobile/mobile_new_user.dart @@ -28,9 +28,9 @@ class MobileNewUserState extends State { bool usernameEnable = true; final codeController = TextEditingController(); - bool enableGetCode; - String getCodeText; - bool canRegister; + late bool enableGetCode; + late String getCodeText; + late bool canRegister; var countDownListener; @@ -88,7 +88,7 @@ class MobileNewUserState extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).mobile_or_email_is_required; } return null; @@ -171,7 +171,7 @@ class MobileNewUserState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).verification_code_is_required; } return null; diff --git a/lib/widgets/mobile/mobile_order_detail.dart b/lib/widgets/mobile/mobile_order_detail.dart index 2a20590..d00c296 100644 --- a/lib/widgets/mobile/mobile_order_detail.dart +++ b/lib/widgets/mobile/mobile_order_detail.dart @@ -37,18 +37,18 @@ class MobileOrderDetail extends StatefulWidget { } class MobileOrderDetailState extends State { - Order order; + late Order order; - LatLng _lastMapPosition; - LatLng customerLatLng; - LatLng deliveryLatLng; - LatLng storeLatLng; + late LatLng _lastMapPosition; + late LatLng customerLatLng; + late LatLng deliveryLatLng; + late LatLng storeLatLng; final Set _markers = {}; final Set _polyLine = {}; - BitmapDescriptor homeIcon; - BitmapDescriptor deliveryIcon; - BitmapDescriptor shopIcon; + late BitmapDescriptor homeIcon; + late BitmapDescriptor deliveryIcon; + late BitmapDescriptor shopIcon; Completer _controller = Completer(); @@ -123,7 +123,7 @@ class MobileOrderDetailState extends State { width: double.infinity, padding: EdgeInsets.only(top: 0.0, bottom: 16.0), child: Text( - order.cartInfo.businessInfo.name, + order.cartInfo!.businessInfo!.name, maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -154,7 +154,7 @@ class MobileOrderDetailState extends State { Icons.phone, ), onTap: () { - Utils.launchURL('tel:${order.businessInfo.phone}'); + Utils.launchURL('tel:${order.businessInfo!.phone}'); }, ), ), @@ -170,8 +170,8 @@ class MobileOrderDetailState extends State { onMapCreated: _onMapCreated, initialCameraPosition: CameraPosition( target: LatLng( - double.parse(order.shippingAddress.lat), - double.parse(order.shippingAddress.lng)), + double.parse(order.shippingAddress!.lat), + double.parse(order.shippingAddress!.lng)), zoom: 11.0, ), onCameraMove: _onCameraMove, @@ -182,14 +182,14 @@ class MobileOrderDetailState extends State { ].toSet(), ), )); - if (order.deliveryDistance != null && order.deliveryDistance.distance != null) { + if (order.deliveryDistance != null && order.deliveryDistance!.distance != null) { col.children.add(Container( padding: EdgeInsets.only(top: 6.0, bottom: 6.0), margin: EdgeInsets.only(bottom: 6.0), child: Text( S.of(context).delivery_distance_token( - order.deliveryDistance.distance.text, - order.deliveryDistance.duration.text + order.deliveryDistance!.distance!.text, + order.deliveryDistance!.duration!.text ), ), decoration: BoxDecoration( @@ -205,7 +205,7 @@ class MobileOrderDetailState extends State { } } - for (CartLineItem lineItem in order.cartInfo.productList) { + for (CartLineItem lineItem in order.cartInfo!.productList) { col.children.add(Container( padding: EdgeInsets.only(top: 16.0, bottom: 0.0), @@ -213,7 +213,7 @@ class MobileOrderDetailState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Util.showImage('${lineItem.product.imagePath}', + Util.showImage('${lineItem.product!.imagePath}', width: 40.0, height: 40.0, fit: BoxFit.fill, @@ -251,7 +251,7 @@ class MobileOrderDetailState extends State { width: 30.0, alignment: Alignment.centerRight, child: Text( - 'x${lineItem.quantity.round()}', + 'x${lineItem.quantity!.round()}', style: TextStyle( fontSize: 14.0, ), @@ -313,8 +313,8 @@ class MobileOrderDetailState extends State { ], ), ); - for (var i = 0; i < order.cartInfo.extraFeeList.length; i++) { - ExtraFee extraFee = order.cartInfo.extraFeeList[i]; + for (var i = 0; i < order.cartInfo!.extraFeeList!.length; i++) { + ExtraFee extraFee = order.cartInfo!.extraFeeList![i]; col.children.add( Row( mainAxisAlignment: MainAxisAlignment.start, @@ -338,7 +338,7 @@ class MobileOrderDetailState extends State { width: 100.0, alignment: Alignment.centerRight, child: Text( - '${extraFee.price.toStringAsFixed(2)}', + '${extraFee.price!.toStringAsFixed(2)}', style: TextStyle( fontSize: 15.0, ), @@ -371,7 +371,7 @@ class MobileOrderDetailState extends State { width: 100.0, alignment: Alignment.centerRight, child: Text( - '${order.totalPrice.toStringAsFixed(2)}', + '${order.totalPrice!.toStringAsFixed(2)}', style: TextStyle( fontSize: 18.0, fontWeight: FontWeight.bold, @@ -481,7 +481,7 @@ class MobileOrderDetailState extends State { margin: EdgeInsets.only(top: 10.0, bottom: 10.0), alignment: Alignment.centerRight, child: Text( - '${order.cartInfo.businessInfo.fullAddress}', + '${order.cartInfo!.businessInfo!.fullAddress}', style: TextStyle( color: Colors.black38, ), @@ -908,19 +908,19 @@ class MobileOrderDetailState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - child: fulfillment.shippingMethod.isNotEmpty && fulfillment.trackingNumber != null && fulfillment.trackingNumber.isNotEmpty ? + child: fulfillment.shippingMethod!.isNotEmpty && fulfillment.trackingNumber != null && fulfillment.trackingNumber!.isNotEmpty ? Text( '${fulfillment.shippingMethod} ${fulfillment.trackingNumber}', overflow: TextOverflow.ellipsis, maxLines: 1, - ) : (fulfillment.shippingMethod.isNotEmpty ? Text( + ) : (fulfillment.shippingMethod!.isNotEmpty ? Text( '${fulfillment.shippingMethod}', overflow: TextOverflow.ellipsis, maxLines: 1, ) : SizedBox.shrink()), ), Container( - child: fulfillment.note != null && fulfillment.note.isNotEmpty ? + child: fulfillment.note != null && fulfillment.note!.isNotEmpty ? Text( '${fulfillment.note}', style: TextStyle( @@ -1060,12 +1060,12 @@ class MobileOrderDetailState extends State { if (!kIsWeb) { if (order.shippingMethod == 'store-delivery' && order.status != Constants.STATUS_COMPLETE && order.status != Constants.STATUS_CANCELLED) { - storeLatLng = LatLng(double.parse(order.businessInfo.address.lat), - double.parse(order.businessInfo.address.lng)); - customerLatLng = LatLng(double.parse(order.shippingAddress.lat), - double.parse(order.shippingAddress.lng)); + storeLatLng = LatLng(double.parse(order.businessInfo!.address!.lat), + double.parse(order.businessInfo!.address!.lng)); + customerLatLng = LatLng(double.parse(order.shippingAddress!.lat), + double.parse(order.shippingAddress!.lng)); deliveryLatLng = - LatLng(order.shipperPosition.lat, order.shipperPosition.lng); + LatLng(order.shipperPosition!.lat, order.shipperPosition!.lng); _polyLine.clear(); _polyLine.add( @@ -1078,7 +1078,7 @@ class MobileOrderDetailState extends State { ], width: 3, points: [ - order.shipperPosition.lat != 0.0 ? deliveryLatLng : storeLatLng, + order.shipperPosition!.lat != 0.0 ? deliveryLatLng : storeLatLng, customerLatLng, ] ) @@ -1103,12 +1103,12 @@ class MobileOrderDetailState extends State { title: S .of(context) .customer, - snippet: order.shippingAddress.addressLine1, + snippet: order.shippingAddress!.addressLine1, ), icon: homeIcon, )); - if (order.shipperPosition.lat != 0.0 && - order.shipperPosition.lng != 0.0) { + if (order.shipperPosition!.lat != 0.0 && + order.shipperPosition!.lng != 0.0) { _markers.add(Marker( markerId: MarkerId('shipper_position'), position: deliveryLatLng, diff --git a/lib/widgets/mobile/mobile_orders.dart b/lib/widgets/mobile/mobile_orders.dart index 544bc4d..1079cc2 100644 --- a/lib/widgets/mobile/mobile_orders.dart +++ b/lib/widgets/mobile/mobile_orders.dart @@ -152,7 +152,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta row.children.add(Expanded( child: Container( child: Text( - order.cartInfo.productList[0].name, + order.cartInfo!.productList![0].name, style: TextStyle( fontSize: 14.0, ), @@ -161,7 +161,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta ), ), )); - if (order.cartInfo.productList.length > 1) { + if (order.cartInfo!.productList!.length > 1) { row.children.add(Container( child: Text( S.of(context).and_more_item_token(Utils.getProductLineInOrder(order.cartInfo)), @@ -176,7 +176,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta width: 80.0, alignment: Alignment.centerRight, child: Text( - '\$${order.totalPrice.toStringAsFixed(2)}', + '\$${order.totalPrice!.toStringAsFixed(2)}', style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -291,7 +291,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta mainAxisAlignment: MainAxisAlignment.start, children: [ Container( - child: Util.showImage('${order.cartInfo.businessInfo.picUrl}', + child: Util.showImage('${order.cartInfo!.businessInfo!.picUrl}', width: 32.0, height: 32.0, fit: BoxFit.fill, @@ -307,7 +307,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta children: [ Container( child: Text( - '${order.cartInfo.businessInfo.name}', + '${order.cartInfo!.businessInfo!.name}', style: TextStyle( fontSize: 20.0, ), diff --git a/lib/widgets/mobile/mobile_pay_now.dart b/lib/widgets/mobile/mobile_pay_now.dart index b579c86..6ec650c 100644 --- a/lib/widgets/mobile/mobile_pay_now.dart +++ b/lib/widgets/mobile/mobile_pay_now.dart @@ -30,9 +30,9 @@ class MobilePayNow extends StatefulWidget { } class MobilePayNowState extends State { - Order order; - List paymentPlatforms; - User _user; + late Order order; + late List paymentPlatforms; + late User _user; @override @@ -74,7 +74,7 @@ class MobilePayNowState extends State { ), ), Text( - '\$${order.totalPrice.toStringAsFixed(2)}', + '\$${order.totalPrice!.toStringAsFixed(2)}', style: TextStyle( fontSize: 24.0, fontWeight: FontWeight.bold, @@ -91,7 +91,7 @@ class MobilePayNowState extends State { ) ), ), - store.state.deviceId != null && store.state.deviceId.isNotEmpty || store.state.tableNumber != null && store.state.tableNumber.isNotEmpty ? + store.state.deviceId != null && store.state.deviceId!.isNotEmpty || store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty ? GestureDetector( child: Container( padding: EdgeInsets.only(top: 20.0, bottom: 20.0, left: 16.0, right: 16.0), diff --git a/lib/widgets/mobile/mobile_product_detail_page.dart b/lib/widgets/mobile/mobile_product_detail_page.dart index 0ac1118..abea27f 100644 --- a/lib/widgets/mobile/mobile_product_detail_page.dart +++ b/lib/widgets/mobile/mobile_product_detail_page.dart @@ -23,10 +23,10 @@ import '../../widgets/general/add_remove_button.dart'; import '../../widgets/general/carousel.dart'; import '../../widgets/general/show_price.dart'; -MediaQueryData mediaQuery; -double statusBarHeight; -double screenHeight; -double screenWidth; +late MediaQueryData mediaQuery; +late double statusBarHeight; +late double screenHeight; +late double screenWidth; class MobileProductDetailPage extends StatefulWidget { final Business business; @@ -44,18 +44,18 @@ class MobileProductDetailPage extends StatefulWidget { class MobileProductDetailPageState extends State with SingleTickerProviderStateMixin { - ShopScrollCoordinator _shopCoordinator; - ShopScrollController _pageScrollController; + late ShopScrollCoordinator _shopCoordinator; + late ShopScrollController _pageScrollController; - TabController _tabController; + late TabController _tabController; - double _sliverAppBarInitHeight; - double _sliverAppBarMaxHeight; + late double _sliverAppBarInitHeight; + late double _sliverAppBarMaxHeight; final double _tabBarHeight = 50; - ProductDetail productDetail; + late ProductDetail productDetail; - bool refresh; + late bool refresh; @override Widget build(BuildContext context) { @@ -204,7 +204,7 @@ class MobileProductDetailPageState extends State mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - (productDetail.subproducts.length > 0) ? + (productDetail.subproducts!.length > 0) ? subProducts(productDetail.subproducts) : SizedBox.shrink(), Container( @@ -219,7 +219,7 @@ class MobileProductDetailPageState extends State Container( padding: EdgeInsets.only(left: 10.0, right: 10.0), child: (productDetail.description2 != null && - !productDetail.description2.isEmpty) + !productDetail.description2!.isEmpty) ? Text( '${productDetail.description2}', style: TextStyle( @@ -343,7 +343,7 @@ class MobileProductDetailPageState extends State Container( padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 5.0), child: Util.showImage( - 'https:${subproduct.product.image}', + 'https:${subproduct.product!.image}', width: 48, height: 48, fit: BoxFit.contain, @@ -363,7 +363,7 @@ class MobileProductDetailPageState extends State child: Container( padding: EdgeInsets.only(left: 12, top: 5), child: Text( - subproduct.product.name, + subproduct.product!.name, style: TextStyle( fontSize: 15.0, ), @@ -374,7 +374,7 @@ class MobileProductDetailPageState extends State width: 80, padding: EdgeInsets.only(left: 12, top: 5, right: 12), child: Text( - '${subproduct.product.price.toStringAsFixed(2)}', + '${subproduct.product!.price!.toStringAsFixed(2)}', style: TextStyle( fontSize: 13, decoration: TextDecoration.lineThrough, @@ -386,7 +386,7 @@ class MobileProductDetailPageState extends State width: 60, padding: EdgeInsets.only(left: 12, top: 5, right: 12), child: Text( - 'x${subproduct.quantity.toStringAsFixed(0)}', + 'x${subproduct.quantity!.toStringAsFixed(0)}', style: TextStyle( fontSize: 13, ), @@ -398,7 +398,7 @@ class MobileProductDetailPageState extends State Container( padding: EdgeInsets.only(left: 12, top: 12, right: 12), child: Text( - '${subproduct.product.description}', + '${subproduct.product!.description}', style: TextStyle( fontSize: 12, color: Colors.black45, @@ -419,9 +419,9 @@ class MobileProductDetailPageState extends State var pages = []; List images = []; images.add(productDetail.image); - for (var i = 0; i < productDetail.images.length; i++) { + for (var i = 0; i < productDetail.images!.length; i++) { // print('>>https:' + productDetail.images[i].image); - images.add(productDetail.images[i].image); + images.add(productDetail.images![i].image); } for (var i = 0; i < images.length; i++) { diff --git a/lib/widgets/mobile/mobile_product_item.dart b/lib/widgets/mobile/mobile_product_item.dart index bba1e0e..015337b 100644 --- a/lib/widgets/mobile/mobile_product_item.dart +++ b/lib/widgets/mobile/mobile_product_item.dart @@ -98,7 +98,7 @@ class MobileProductItemState extends State { new Container( child: widget.business.showMonthlySold ? Text( - S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), + S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)), style: new TextStyle( fontSize: 9.0 ), diff --git a/lib/widgets/mobile/mobile_renew_license.dart b/lib/widgets/mobile/mobile_renew_license.dart index b3e8936..8131080 100644 --- a/lib/widgets/mobile/mobile_renew_license.dart +++ b/lib/widgets/mobile/mobile_renew_license.dart @@ -97,7 +97,7 @@ class MobileRenewLicenseState extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).please_enter_group_number; } return null; diff --git a/lib/widgets/mobile/mobile_renew_minioffice.dart b/lib/widgets/mobile/mobile_renew_minioffice.dart index 0ed1045..1b2edce 100644 --- a/lib/widgets/mobile/mobile_renew_minioffice.dart +++ b/lib/widgets/mobile/mobile_renew_minioffice.dart @@ -104,7 +104,7 @@ class MobileRenewMiniOfficeState extends State { ); } - Widget buildLine(String name, String value, {double nameSize, double valueSize}) { + Widget buildLine(String name, String value, {double? nameSize, double? valueSize}) { Row row = Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/widgets/mobile/mobile_reset_password.dart b/lib/widgets/mobile/mobile_reset_password.dart index 976ab98..8a65f5a 100644 --- a/lib/widgets/mobile/mobile_reset_password.dart +++ b/lib/widgets/mobile/mobile_reset_password.dart @@ -27,10 +27,10 @@ class MobileResetPasswordState extends State { final passwordController = TextEditingController(); final passwordAgainController = TextEditingController(); - bool passwordVisible; - bool passwordAgainVisible; + late bool passwordVisible; + late bool passwordAgainVisible; - bool canReset; + late bool canReset; @override void initState() { @@ -105,7 +105,7 @@ class MobileResetPasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } return null; @@ -159,10 +159,10 @@ class MobileResetPasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } - if (value.trim() != passwordController.text.trim()) { + if (value!.trim() != passwordController.text.trim()) { return S.of(context).password_is_not_match_password_again; } return null; diff --git a/lib/widgets/mobile/mobile_search_place.dart b/lib/widgets/mobile/mobile_search_place.dart index c805cb5..b590189 100644 --- a/lib/widgets/mobile/mobile_search_place.dart +++ b/lib/widgets/mobile/mobile_search_place.dart @@ -107,7 +107,7 @@ class MobileSearchPlaceState extends State { ); if (result is DioError) { if (result.response != null) { - throw RuntimeError(result.response.data['message']); + throw RuntimeError(result.response!.data['message']); } else { throw RuntimeError(result.message); } diff --git a/lib/widgets/mobile/mobile_set_password.dart b/lib/widgets/mobile/mobile_set_password.dart index 4de71ea..e488fe4 100644 --- a/lib/widgets/mobile/mobile_set_password.dart +++ b/lib/widgets/mobile/mobile_set_password.dart @@ -28,10 +28,10 @@ class MobileSetPasswordState extends State { final passwordController = TextEditingController(); final passwordAgainController = TextEditingController(); - bool passwordVisible; - bool passwordAgainVisible; + late bool passwordVisible; + late bool passwordAgainVisible; - bool canReset; + late bool canReset; @override void initState() { @@ -106,7 +106,7 @@ class MobileSetPasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } return null; @@ -160,10 +160,10 @@ class MobileSetPasswordState extends State { fontSize: 18.0 ), validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).password_is_required; } - if (value.trim() != passwordController.text.trim()) { + if (value!.trim() != passwordController.text.trim()) { return S.of(context).password_is_not_match_password_again; } return null; diff --git a/lib/widgets/mobile/mobile_store_product_search.dart b/lib/widgets/mobile/mobile_store_product_search.dart index 6308252..f61ac85 100644 --- a/lib/widgets/mobile/mobile_store_product_search.dart +++ b/lib/widgets/mobile/mobile_store_product_search.dart @@ -105,7 +105,7 @@ class MobileStoreProductSearchState extends State { ); if (result is DioError) { if (result.response != null) { - throw RuntimeError(result.response.data); + throw RuntimeError(result.response!.data); } else { throw RuntimeError(result.message); } diff --git a/lib/widgets/mobile/mobile_user_profile.dart b/lib/widgets/mobile/mobile_user_profile.dart index ec626fe..e8c4c61 100644 --- a/lib/widgets/mobile/mobile_user_profile.dart +++ b/lib/widgets/mobile/mobile_user_profile.dart @@ -27,10 +27,10 @@ class MobileUserProfile extends StatefulWidget { } class MobileUserProfileState extends State { - User _user; + late User _user; - bool _showProgress; - double _progress; + late bool _showProgress; + late double _progress; @override Widget build(BuildContext context) { @@ -229,7 +229,7 @@ class MobileUserProfileState extends State { ), Container( child: Text( - _user.mobile != null && _user.mobile.isNotEmpty ? Utils.safePhoneNumber(_user.mobile) : S.of(context).not_binding, + _user.mobile != null && _user.mobile!.isNotEmpty ? Utils.safePhoneNumber(_user.mobile) : S.of(context).not_binding, style: TextStyle( color: Colors.grey, ), @@ -282,7 +282,7 @@ class MobileUserProfileState extends State { ), Container( child: Text( - _user.email != null && _user.email.isNotEmpty ? Utils.safePhoneNumber(_user.email) : S.of(context).not_binding, + _user.email != null && _user.email!.isNotEmpty ? Utils.safePhoneNumber(_user.email) : S.of(context).not_binding, style: TextStyle( color: Colors.grey, ), @@ -393,7 +393,7 @@ class MobileUserProfileState extends State { ), autofocus: true, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).nickname_is_required; } return null; diff --git a/lib/widgets/mobile/mobile_view_blog.dart b/lib/widgets/mobile/mobile_view_blog.dart index ba1f488..889c592 100644 --- a/lib/widgets/mobile/mobile_view_blog.dart +++ b/lib/widgets/mobile/mobile_view_blog.dart @@ -28,7 +28,7 @@ class MobileViewBlog extends StatefulWidget { } class MobileViewBlogState extends State { - Blog blog; + late Blog blog; @override void initState() { diff --git a/lib/widgets/mobile/mobile_view_ticket.dart b/lib/widgets/mobile/mobile_view_ticket.dart index 0242890..16a6d2a 100644 --- a/lib/widgets/mobile/mobile_view_ticket.dart +++ b/lib/widgets/mobile/mobile_view_ticket.dart @@ -34,7 +34,7 @@ class MobileViewTicket extends StatefulWidget { class MobileViewTicketState extends State { final GlobalKey _formKey = GlobalKey(); - Ticket ticket; + late Ticket ticket; final issueMsgController = TextEditingController(); @@ -123,7 +123,7 @@ class MobileViewTicketState extends State { width: double.maxFinite, padding: EdgeInsets.only(top: 8.0, left: 16.0, right: 16.0, bottom: 24.0), child: Text( - '${ticket.issue.msg}', + '${ticket.issue!.msg}', style: TextStyle( color: Colors.black54, fontSize: 14.0, @@ -141,7 +141,7 @@ class MobileViewTicketState extends State { Container( width: double.maxFinite, padding: EdgeInsets.only(top: 16.0, bottom: 16.0, left: 16.0, right: 16.0), - child: showGalleryImages(mainContext, ticket.issue.files), + child: showGalleryImages(mainContext, ticket.issue!.files), decoration: BoxDecoration( border: Border( bottom: BorderSide( @@ -171,7 +171,7 @@ class MobileViewTicketState extends State { ], ); - if (ticket.followUps.length > 0) { + if (ticket.followUps!.length > 0) { view.children.add( Container( width: double.maxFinite, @@ -185,8 +185,8 @@ class MobileViewTicketState extends State { ), ), ); - for (int i = 0; i < ticket.followUps.length; i++) { - FollowUp followUp = ticket.followUps[i]; + for (int i = 0; i < ticket.followUps!.length; i++) { + FollowUp followUp = ticket.followUps![i]; view.children.add( Container( width: double.maxFinite, @@ -294,7 +294,7 @@ class MobileViewTicketState extends State { ), autofocus: false, validator: (String? value) { - if (value.trim().isEmpty) { + if (value!.trim().isEmpty) { return S.of(context).this_field_is_required; } return null; @@ -353,7 +353,7 @@ class MobileViewTicketState extends State { ), ); - if (ticket.followUps.length > 0) { + if (ticket.followUps!.length > 0) { view.children.add( Container( width: double.maxFinite, @@ -393,7 +393,7 @@ class MobileViewTicketState extends State { padding: EdgeInsets.only(left: 20.0, right: 20.0, top: 0.0, bottom: 30.0), child: TextLink( S.of(context).new_ticket, - '/new-ticket/${ticket.store.id}', + '/new-ticket/${ticket.store!.id}', ), ), ); @@ -690,7 +690,7 @@ class MobileViewTicketState extends State { child: Text(S.of(context).ok), onPressed: () { Routes.router.navigateTo(context, - '/my-support/${ticket.store.id}', + '/my-support/${ticket.store!.id}', replace: true, ); }, diff --git a/lib/widgets/mobile/product_item.dart b/lib/widgets/mobile/product_item.dart index 4cd9812..93b32b6 100644 --- a/lib/widgets/mobile/product_item.dart +++ b/lib/widgets/mobile/product_item.dart @@ -64,7 +64,7 @@ class ProductItemState extends State { width: widget.imageWidth, height: widget.imageWidth, child: GestureDetector( - child: onHover && widget.product.secondImagePath.isNotEmpty ? + child: onHover && widget.product.secondImagePath!.isNotEmpty ? Util.showImage('${widget.product.secondImagePath}', fit: BoxFit.fill, ) : @@ -127,7 +127,7 @@ class ProductItemState extends State { new Container( child: widget.business.showMonthlySold ? Text( - S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), + S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)), style: new TextStyle( fontSize: 9.0 ), @@ -157,7 +157,7 @@ class ProductItemState extends State { width: widget.imageWidth, height: widget.imageWidth, child: GestureDetector( - child: onHover && widget.product.secondImagePath.isNotEmpty ? + child: onHover && widget.product.secondImagePath!.isNotEmpty ? Util.showImage('${widget.product.secondImagePath}', fit: BoxFit.fill, ) : @@ -212,7 +212,7 @@ class ProductItemState extends State { new Container( child: widget.business.showMonthlySold ? Text( - S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), + S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)), style: new TextStyle( fontSize: 9.0 ), diff --git a/lib/widgets/mobile/product_search.dart b/lib/widgets/mobile/product_search.dart index 6c1ee37..8ba3001 100644 --- a/lib/widgets/mobile/product_search.dart +++ b/lib/widgets/mobile/product_search.dart @@ -113,7 +113,7 @@ class ProductSearchState extends State { ); if (result is DioError) { if (result.response != null) { - throw RuntimeError(result.response.data); + throw RuntimeError(result.response!.data); } else { throw RuntimeError(result.message); } diff --git a/lib/widgets/mobile/shop.dart b/lib/widgets/mobile/shop.dart index 34eb82d..be85c69 100644 --- a/lib/widgets/mobile/shop.dart +++ b/lib/widgets/mobile/shop.dart @@ -37,10 +37,10 @@ import 'product_item.dart'; import 'product_search.dart'; import 'shopping_cart_bar.dart'; -MediaQueryData mediaQuery; -double statusBarHeight; -double screenWidth; -double screenHeight; +late MediaQueryData mediaQuery; +late double statusBarHeight; +late double screenWidth; +late double screenHeight; class Shop extends StatefulWidget { final int businessId; @@ -56,10 +56,10 @@ class ShopState extends State GlobalKey _scaffoldKey = new GlobalKey(); - Business _business; - List _categoryProducts; - List _featuredProducts; - List _hotSaleProducts; + late Business _business; + late List _categoryProducts; + late List _featuredProducts; + late List _hotSaleProducts; List _prompts = []; bool checkCloseFlag = false; @@ -79,22 +79,22 @@ class ShopState extends State bool refresh = false; - ShopScrollCoordinator _shopCoordinator; - ShopScrollController _pageScrollController; - TabController _tabController; + late ShopScrollCoordinator _shopCoordinator; + late ShopScrollController _pageScrollController; + late TabController _tabController; final double _sliverAppBarInitHeight = 150.0; final double _tabBarHeight = 50.0; - double _sliverAppBarMaxHeight; + late double _sliverAppBarMaxHeight; - ShopScrollController _listScrollController1; - ShopScrollController _listScrollController2; - ShopScrollController _listScrollController3; + late ShopScrollController _listScrollController1; + late ShopScrollController _listScrollController2; + late ShopScrollController _listScrollController3; AnimationPointManager _animationPointManager = AnimationPointManager(); GlobalKey stackKey = GlobalKey(); GlobalKey endKey = GlobalKey(); - List comments; + late List comments; int _commentPage = 1; int _commentPageCount = 1; bool _commentLoadingFinish = false; @@ -102,13 +102,13 @@ class ShopState extends State RefreshController(initialRefresh: true); PanelController panelController = PanelController(); - SlidingUpPanel _slidUpShoppingCart; + late SlidingUpPanel _slidUpShoppingCart; - SliverPersistentHeader promotHeader; + late SliverPersistentHeader promotHeader; bool _animationFinish = true; - Carousel slidingGellery; + late Carousel slidingGellery; // StreamSubscription onProductWillAddToCartSubscription; // StreamSubscription onProductWillRemoveFromCartSubscription; @@ -247,7 +247,7 @@ class ShopState extends State mainAxisAlignment: MainAxisAlignment.start, children: [], ); - for (var i = 0; i < _business.promoProducts.length; i++) { + for (var i = 0; i < _business.promoProducts!.length; i++) { promotRow.children.add(Container( padding: EdgeInsets.only( left: 10.0, @@ -286,17 +286,17 @@ class ShopState extends State GestureDetector( child: Container( child: Util.showImage( - _business.promoProducts[i].imagePath, + _business.promoProducts![i].imagePath, width: 110.0, ), ), onTap: () { - _showProductDetail(_business.promoProducts[i]); + _showProductDetail(_business.promoProducts![i]); }, ), Container( child: Text( - _business.promoProducts[i].name, + _business.promoProducts![i].name, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 14.0), @@ -306,13 +306,13 @@ class ShopState extends State mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ ShowPrice( - _business.promoProducts[i].price, + _business.promoProducts![i].price, currencySign: '\$', - regularPrice: _business.promoProducts[i].regularPrice, + regularPrice: _business.promoProducts![i].regularPrice, ), Container( child: AddRemoveButton( - product: _business.promoProducts[i], + product: _business.promoProducts![i], business: _business, addOnly: true, ), @@ -581,7 +581,7 @@ class ShopState extends State mainAxisAlignment: MainAxisAlignment.start, children: [], ); - if (comment.images.length > 0) { + if (comment.images!.length > 0) { for (ProductImage image in comment.images) { imageRow.children.add( GestureDetector( @@ -609,7 +609,7 @@ class ShopState extends State } Widget replyWidget = SizedBox.shrink(); if (comment.replyFromStore != null && - comment.replyFromStore.isNotEmpty) { + comment.replyFromStore!.isNotEmpty) { replyWidget = Container( child: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -681,7 +681,7 @@ class ShopState extends State Container( child: SmoothStarRating( starCount: 5, - rating: comment.rating.toDouble(), + rating: comment.rating!.toDouble(), size: 12.0, filledIconData: Icons.star, color: Colors.green, @@ -772,18 +772,18 @@ class ShopState extends State children: [], ); addressColumn.children.add(new Text( - _business.address.addressLine1 + - (_business.address.addressLine2.isNotEmpty - ? ' ' + _business.address.addressLine2 + _business.address!.addressLine1! + + (_business.address!.addressLine2!.isNotEmpty + ? ' ' + _business.address!.addressLine2 : ''), style: new TextStyle(fontSize: 13.0, color: const Color(0xFFEEEEEE)), )); addressColumn.children.add(new Text( - _business.address.city + + _business.address!.city! + ', ' + - _business.address.state + + _business.address!.state + ', ' + - _business.address.zip, + _business.address!.zip, style: new TextStyle(fontSize: 13.0, color: const Color(0xFFEEEEEE)), )); @@ -800,16 +800,16 @@ class ShopState extends State color: Colors.white, )); distanceRow.children.add(new Text( - _business.distanceInfo.distance != null - ? _business.distanceInfo.distance.text + _business.distanceInfo!.distance != null + ? _business.distanceInfo!.distance!.text : '***' + ' / ', style: new TextStyle(color: const Color(0xFFEEEEEE), fontSize: 13.0), )); var duration = Duration( - seconds: (_business.distanceInfo.duration != null - ? _business.distanceInfo.duration.value - : 30) + - _business.shippingTime * 60); + seconds: (_business.distanceInfo!.duration != null + ? _business.distanceInfo!.duration!.value + : 30)! + + _business.shippingTime! * 60); var hours = duration.inHours.remainder(60); var minutes = duration.inMinutes.remainder(60); distanceRow.children.add(new Text( @@ -910,9 +910,9 @@ class ShopState extends State color: Colors.white, ), new Text( - _business.openingTime[0].openTime + + _business.openingTime![0].openTime! + ':00 - ' + - _business.openingTime[0].closeTime + + _business.openingTime![0].closeTime + ':00', style: new TextStyle( fontSize: 13.0, color: const Color(0xFFEEEEEE)), @@ -941,7 +941,7 @@ class ShopState extends State mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - _business.bulletin.isNotEmpty ? Row( + _business.bulletin!.isNotEmpty ? Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( @@ -956,7 +956,7 @@ class ShopState extends State width: mediaQuery.size.width - 30.0, padding: EdgeInsets.only(right: 10.0, bottom: 10.0), child: new Text( - _business.bulletin.isEmpty ? '' : _business.bulletin, + _business.bulletin!.isEmpty ? '' : _business.bulletin, softWrap: true, style: new TextStyle( fontSize: 12.0, color: const Color(0xFFDDDDDD)), @@ -965,7 +965,7 @@ class ShopState extends State ), ], ) : SizedBox.shrink(), - _business.description.isNotEmpty ? Column( + _business.description!.isNotEmpty ? Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -1009,7 +1009,7 @@ class ShopState extends State padding: EdgeInsets.only(left: 10.0, right: 10.0, bottom: 10.0), child: slidingGellery, ) : SizedBox.shrink(), - _business.policy.isNotEmpty ? Column( + _business.policy!.isNotEmpty ? Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -1098,11 +1098,11 @@ class ShopState extends State List _buildBanners(BuildContext context) { var pages = []; - for (var i = 0; i < _business.slideImages.length; i++) { + for (var i = 0; i < _business.slideImages!.length; i++) { pages.add(new GestureDetector( child: new Container( child: Util.showImage( - _business.slideImages[i].imageUrl, + _business.slideImages![i].imageUrl, fit: BoxFit.cover, ), ), @@ -1139,11 +1139,11 @@ class ShopState extends State CartInfo cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, _business); if (cartInfo != null && - cartInfo.businessInfo.id == _business.id && + cartInfo.businessInfo!.id == _business.id && cartInfo.productList != null) { - for (var i = 0; i < cartInfo.productList.length; i++) { - if (cartInfo.productList[i].product.categoryId == cp.id) { - qtyInCategory += cartInfo.productList[i].quantity.round(); + for (var i = 0; i < cartInfo.productList!.length; i++) { + if (cartInfo.productList![i].product!.categoryId == cp.id) { + qtyInCategory += cartInfo.productList![i].quantity!.round(); } } } @@ -1213,7 +1213,7 @@ class ShopState extends State } void _selectCategory(int index) { - if (displayProductByCategoryClick && _categoryProducts[index].id > 0) { + if (displayProductByCategoryClick && _categoryProducts[index].id! > 0) { categoryId = _categoryProducts[index].id; loadProducts(); return; @@ -1221,7 +1221,7 @@ class ShopState extends State double height = 0.0; for (int i = 0; i < index; ++i) { height += _categoryDescHeight + - _categoryProducts[i].products.length * _productHeight; + _categoryProducts[i].products!.length * _productHeight; } if (height > _listScrollController1.position.maxScrollExtent) { height = _listScrollController1.position.maxScrollExtent; @@ -1237,7 +1237,7 @@ class ShopState extends State _categoryIndexChange = false; }); print( - 'height: $height, index: $index, ${_categoryProducts[0].products.length}'); + 'height: $height, index: $index, ${_categoryProducts[0].products!.length}'); if (mounted) { setState(() { _categoryIndex = index; @@ -1272,7 +1272,7 @@ class ShopState extends State if (height > 0) { for (int i = 0; i < _categoryProducts.length; ++i) { double categoryHeight = _categoryDescHeight + - _categoryProducts[i].products.length * _productHeight; + _categoryProducts[i].products!.length * _productHeight; if (height >= cHeight && height < cHeight + categoryHeight) { return i; } @@ -1311,7 +1311,7 @@ class ShopState extends State int numCategoriesHasProducts() { int num = 0; for (CategoryProducts cp in _categoryProducts) { - if (cp.products.length > 0) { + if (cp.products!.length > 0) { num += 1; } } @@ -1362,7 +1362,7 @@ class ShopState extends State }); } - if (cp.products.length == 0) { + if (cp.products!.length == 0) { return SizedBox.shrink(); } @@ -1403,7 +1403,7 @@ class ShopState extends State ), ), new Visibility( - visible: cp.description.isNotEmpty, + visible: cp.description!.isNotEmpty, child: new Text( cp.description, overflow: TextOverflow.ellipsis, @@ -1448,7 +1448,7 @@ class ShopState extends State ), ); } else { - if (cp.products.length < Constants.ORDERS_PER_PAGE) { + if (cp.products!.length < Constants.ORDERS_PER_PAGE) { col.children.add( Container( padding: EdgeInsets.all(12.0), @@ -1620,7 +1620,7 @@ class ShopState extends State displayProductByCategoryClickIndicator = S.of(context).end_of_the_list; } else { - if (moreCategoryProducts[0].products.length < Constants.ORDERS_PER_PAGE) { + if (moreCategoryProducts[0].products!.length < Constants.ORDERS_PER_PAGE) { _productCurrentPage = 0; displayProductByCategoryClickIndicator = S.of(context).end_of_the_list; @@ -1631,7 +1631,7 @@ class ShopState extends State CategoryProducts currentCp = getCategoryProductByCategoryId(categoryId); if (currentCp != null) { - currentCp.products.addAll(moreCategoryProducts[0].products); + currentCp.products!.addAll(moreCategoryProducts[0].products); } else { _productCurrentPage = 0; displayProductByCategoryClickIndicator = @@ -1653,16 +1653,16 @@ class ShopState extends State } CartLineItem _newCartLineItem( - {int id, - double price, - Product product, - String name, - String description, - double quantity}) { + {int? id, + double? price, + Product? product, + String? name, + String? description, + double? quantity}) { CartLineItem lineItem = CartLineItem(); lineItem.unitPrice = price; lineItem.product = product; - lineItem.name = product.name; + lineItem.name = product!.name; lineItem.description = description; lineItem.quantity = quantity; return lineItem; diff --git a/lib/widgets/mobile/shopping_cart_bar.dart b/lib/widgets/mobile/shopping_cart_bar.dart index b211db9..f043e3f 100644 --- a/lib/widgets/mobile/shopping_cart_bar.dart +++ b/lib/widgets/mobile/shopping_cart_bar.dart @@ -35,21 +35,21 @@ class ShoppingCartBar extends StatefulWidget { } class ShoppingCartBarState extends State { - 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 { }, ), ); - 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 { ], ), 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 { 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 { ), ), ), - 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 { 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 { children: [ Container( child: Text( - '${item.totalPrice.toStringAsFixed(2)}', + '${item.totalPrice!.toStringAsFixed(2)}', style: TextStyle( color: Colors.redAccent, fontSize: 14.0, diff --git a/tools/nullfix.py b/tools/nullfix.py new file mode 100644 index 0000000..a7eb4bf --- /dev/null +++ b/tools/nullfix.py @@ -0,0 +1,175 @@ +#!/usr/bin/env python3 +""" +nullfix.py — dart analyze 驱动的空安全批量修复(保守、带语法损坏自检)。 + +处理的规则(全部由 analyzer 位置驱动,逐轮迭代): + 1. unchecked_use_of_nullable_value -> 在接收者后插 '!'(属性/方法/[]/运算符) + 2. not_initialized_non_nullable_instance_field / _variable + -> 字段/变量改为可空(在类型后插 '?'),跳过 return/this./关键词行 + 3. missing_default_value_for_parameter + -> 参数改为可空(类型后插 '?'),跳过 field-formal this.x + +不处理(需语义判断): argument_type_not_assignable / invalid_assignment + (这两类留给后续:多为 nullable 传给非空形参,常伴随 1/2 解决后自动减少) + +每轮结束检测 expected_token / missing_identifier(语法损坏),有则中止。 + +用法: python3 tools/nullfix.py [file] [--max-rounds N] +""" +import re, subprocess, sys, os + +ROUNDS = 40 +args=[] +i=0 +while i=0 and line[j]==' ': j-=1 + if j<0 or line[j]=='!': continue + if line[j].isalnum() or line[j] in '_)?]': return line[:j+1]+'!'+line[j+1:] + return None + return None + +def insert_late(line): + stripped=line.strip() + if not stripped or stripped.startswith('late '): return None + head=stripped.split(';')[0] + if '?' in head or '=' in head: return None # 已可空/已初始化 + indent=line[:len(line)-len(stripped)] + if stripped.startswith('static '): return indent+'static late '+stripped[len('static '):] + if stripped.startswith('external '): return indent+'external late '+stripped[len('external '):] + return indent+'late '+stripped + +def insert_nullable_before_name(line, name, col0): + """把 'Type name' 改为 'Type? name'。跳过 field-formal(this.)、关键词行。""" + stripped=line.strip() + first=stripped.split(' ')[0] if stripped else '' + if first.rstrip(')').rstrip('(') in KEYWORDS: return None + idx=find_name_col(line, name, col0) + if idx is None: return None + # name 前一个非空字符 + j=idx-1 + while j>=0 and line[j] in ' \t': j-=1 + if j<0: return None + if line[j]=='.': return None # field-formal this.name + if line[j]=='?': return None # 已可空 + # j 应是类型末尾(字母/>/)/]) + if not (line[j].isalnum() or line[j] in '_>]?)'): return None + return line[:j+1]+'?'+line[j+1:] + +def apply_round(errs): + changed=0; files={} + def get(path): + if path not in files: + files[path]=open('lib/'+path).read().split('\n') + return files[path] + def flush(): + for p,ls in files.items(): + open('lib/'+p,'w').write('\n'.join(ls)) + for path,line,col,msg,rule in errs: + if not os.path.exists('lib/'+path): continue + L=get(path) + if line>len(L): continue + old=L[line-1]; new=old + if rule=='unchecked_use_of_nullable_value': + cls=classify_use(msg) + if cls: new=insert_bang(old, col-1, cls[0], cls[1]) + elif rule=='missing_default_value_for_parameter': + nm=NAME.search(msg) + if nm: new=insert_nullable_before_name(old, nm.group(1), col-1) + elif rule in ('not_initialized_non_nullable_instance_field','not_initialized_non_nullable_variable'): + new=insert_late(old) + if new and new!=old: + L[line-1]=new; changed+=1 + flush() + return changed + +rounds=0 +while rounds