From e7ce0f7baec806328a77c1ae5062cd31e2c206ed Mon Sep 17 00:00:00 2001 From: peima Date: Sun, 12 Jul 2026 04:33:48 +0800 Subject: [PATCH] final --- lib/dialog/image_viewer.dart | 3 +- lib/dialog/logout_dialog.dart | 21 +- lib/events/events.dart | 2 +- lib/main.dart | 60 +- lib/models/address.dart | 30 +- lib/models/business.dart | 2 +- lib/models/cart_info.dart | 38 +- lib/models/cart_line_item.dart | 22 +- lib/models/coupon.dart | 2 +- lib/models/distance_info.dart | 6 +- lib/models/order.dart | 16 +- lib/models/payment_platform.dart | 30 +- lib/models/position.dart | 2 +- lib/models/product.dart | 34 +- lib/models/product_attribute.dart | 2 +- lib/models/waiting_line.dart | 4 +- lib/pages/attribute_selection.dart | 15 +- lib/pages/blog.dart | 20 +- lib/pages/buy_service.dart | 21 +- lib/pages/change_mobile_or_email.dart | 18 +- lib/pages/change_password.dart | 16 +- lib/pages/checkout.dart | 10 +- lib/pages/contact_us.dart | 12 +- lib/pages/coupons.dart | 10 +- lib/pages/create_online_store_1.dart | 10 +- lib/pages/download.dart | 24 +- lib/pages/edit_address.dart | 15 +- lib/pages/forgot_password.dart | 18 +- lib/pages/home.dart | 34 +- lib/pages/igoshow_learn_more.dart | 20 +- lib/pages/login.dart | 20 +- lib/pages/me.dart | 20 +- lib/pages/minipos_learn_more.dart | 59 +- lib/pages/my_addresses.dart | 11 +- lib/pages/my_cards.dart | 8 +- lib/pages/my_support.dart | 11 +- lib/pages/new_address.dart | 15 +- lib/pages/new_comment.dart | 10 +- lib/pages/new_ticket.dart | 21 +- lib/pages/new_user.dart | 18 +- lib/pages/order_detail.dart | 10 +- lib/pages/pay_now.dart | 10 +- lib/pages/plain_page.dart | 14 +- lib/pages/product_detail_page.dart | 10 +- lib/pages/product_search.dart | 10 +- lib/pages/renew_license.dart | 10 +- lib/pages/renew_minioffice.dart | 12 +- lib/pages/reset_password.dart | 18 +- lib/pages/search_place.dart | 11 +- lib/pages/set_password.dart | 18 +- lib/pages/shop.dart | 14 +- lib/pages/store_product_search.dart | 18 +- lib/pages/stripe_pay_web.dart | 10 +- lib/pages/user_profile.dart | 18 +- lib/pages/view_blog.dart | 19 +- lib/pages/view_ticket.dart | 19 +- lib/routes.dart | 116 +- lib/store/actions.dart | 6 +- lib/store/reducer/cart_info_reducer.dart | 6 +- lib/store/reducer/context_reducer.dart | 6 +- lib/store/reducer/device_id_reducer.dart | 6 +- lib/store/reducer/fcmtoken_reducer.dart | 6 +- lib/store/reducer/last_visit_reducer.dart | 6 +- lib/store/reducer/locale_reducer.dart | 6 +- lib/store/reducer/locate_address_reducer.dart | 6 +- lib/store/reducer/redirect_route_reducer.dart | 6 +- lib/store/reducer/table_number_reducer.dart | 6 +- lib/store/reducer/user_reducer.dart | 6 +- lib/store/state/app_state.dart | 24 +- lib/utils/double_back_to_close_app.dart | 12 +- lib/utils/fake_iframe_web.dart | 6 +- lib/utils/http_util.dart | 119 ++- lib/utils/shop_scroll_controller.dart | 12 +- lib/utils/shop_scroll_coordinator.dart | 32 +- lib/utils/shop_scroll_position.dart | 32 +- lib/utils/util_io.dart | 205 +--- lib/utils/util_web.dart | 52 +- lib/utils/utils.dart | 305 +++--- lib/widgets/desktop/desktop_buy_service.dart | 4 +- lib/widgets/desktop/desktop_edit_address.dart | 106 +- .../desktop/desktop_index_main_content_1.dart | 7 +- .../desktop/desktop_index_main_content_2.dart | 24 +- .../desktop/desktop_index_main_content_3.dart | 4 +- .../desktop/desktop_navigationbar.dart | 18 +- lib/widgets/desktop/desktop_new_address.dart | 90 +- .../desktop/desktop_stripe_pay_web.dart | 57 +- lib/widgets/general/add_remove_button.dart | 119 ++- .../general/animation_point_manager.dart | 46 +- .../general/attribute/check_options.dart | 96 +- .../general/attribute/options_base.dart | 10 +- .../general/attribute/qty_options.dart | 116 +- .../general/attribute/radio_options.dart | 54 +- lib/widgets/general/bottom_nav.dart | 2 +- lib/widgets/general/breadcrumbs.dart | 36 +- lib/widgets/general/carousel.dart | 42 +- .../double_back_to_close_app_wrapper.dart | 6 +- lib/widgets/general/download_item.dart | 16 +- lib/widgets/general/index_carousel.dart | 10 +- lib/widgets/general/index_main_content_1.dart | 10 +- lib/widgets/general/index_main_content_2.dart | 10 +- lib/widgets/general/index_main_content_3.dart | 10 +- lib/widgets/general/navigationbar.dart | 20 +- lib/widgets/general/navigationbar_logo.dart | 2 +- .../general/parabolic_animation_widget.dart | 42 +- .../payment_verification_code_dialog.dart | 12 +- .../general/popup_animation_widget.dart | 18 +- lib/widgets/general/read_more_text.dart | 28 +- lib/widgets/general/show_price.dart | 10 +- lib/widgets/general/sliding_up_panel.dart | 174 +-- lib/widgets/general/stripe_pay.dart | 35 +- lib/widgets/general/text_link.dart | 98 +- lib/widgets/mobile/create_online_store_1.dart | 26 +- .../mobile/mobile_attribute_selection.dart | 87 +- lib/widgets/mobile/mobile_blog.dart | 16 +- lib/widgets/mobile/mobile_buy_service.dart | 36 +- .../mobile/mobile_change_mobile_or_email.dart | 42 +- .../mobile/mobile_change_password.dart | 28 +- lib/widgets/mobile/mobile_checkout.dart | 247 +++-- lib/widgets/mobile/mobile_contact_us.dart | 14 +- lib/widgets/mobile/mobile_coupons.dart | 19 +- lib/widgets/mobile/mobile_download_apps.dart | 2 +- lib/widgets/mobile/mobile_edit_address.dart | 110 +- .../mobile/mobile_forgot_password.dart | 26 +- .../mobile/mobile_igoshow_learn_more.dart | 2 +- lib/widgets/mobile/mobile_index_carousel.dart | 2 +- .../mobile/mobile_index_main_content_1.dart | 6 +- .../mobile/mobile_index_main_content_2.dart | 14 +- .../mobile/mobile_index_main_content_3.dart | 14 +- lib/widgets/mobile/mobile_login.dart | 43 +- lib/widgets/mobile/mobile_me.dart | 65 +- .../mobile/mobile_minipos_learn_more.dart | 2 +- lib/widgets/mobile/mobile_my_addresses.dart | 16 +- lib/widgets/mobile/mobile_my_cards.dart | 13 +- lib/widgets/mobile/mobile_my_support.dart | 16 +- .../mobile/mobile_navigation_drawer.dart | 6 +- lib/widgets/mobile/mobile_navigationbar.dart | 18 +- lib/widgets/mobile/mobile_new_address.dart | 90 +- lib/widgets/mobile/mobile_new_comment.dart | 48 +- lib/widgets/mobile/mobile_new_ticket.dart | 22 +- lib/widgets/mobile/mobile_new_user.dart | 26 +- lib/widgets/mobile/mobile_order_detail.dart | 152 +-- lib/widgets/mobile/mobile_orders.dart | 49 +- lib/widgets/mobile/mobile_pay_now.dart | 45 +- lib/widgets/mobile/mobile_stripe_pay_web.dart | 35 +- linux/flutter/generated_plugin_registrant.cc | 8 +- linux/flutter/generated_plugins.cmake | 2 +- macos/Flutter/GeneratedPluginRegistrant.swift | 16 +- pubspec.lock | 996 ++++++++++-------- pubspec.yaml | 95 +- .../flutter/generated_plugin_registrant.cc | 12 +- windows/flutter/generated_plugins.cmake | 2 +- 151 files changed, 2765 insertions(+), 2947 deletions(-) diff --git a/lib/dialog/image_viewer.dart b/lib/dialog/image_viewer.dart index a745584..c35f3c8 100644 --- a/lib/dialog/image_viewer.dart +++ b/lib/dialog/image_viewer.dart @@ -3,10 +3,9 @@ import 'package:flutter/material.dart'; import 'package:photo_view/photo_view.dart'; class ImageViewer extends StatefulWidget { - final Key key; final ImageProvider imageProvider; - ImageViewer(this.imageProvider, {this.key}) : + ImageViewer(this.imageProvider, {Key? key}) : super(key: key); @override diff --git a/lib/dialog/logout_dialog.dart b/lib/dialog/logout_dialog.dart index d9bf24a..5699b88 100644 --- a/lib/dialog/logout_dialog.dart +++ b/lib/dialog/logout_dialog.dart @@ -33,18 +33,15 @@ AlertDialog logoutDialog(BuildContext context) { .yes_i_am_sure), onPressed: () { Navigator.of(context).pop(); - Utils.getBox().then((box) { - box.delete(Constants.KEY_USER_ID); - box.delete( - Constants.KEY_ACCESS_TOKEN); - store.dispatch( - new UpdateCurrentUser(null)); - eventBus.fire( - new OnCurrentUserUpdated()); - Routes.router.navigateTo( - context, '/', replace: true, - clearStack: true); - }); + Utils.prefs?.remove(Constants.KEY_USER_ID); + Utils.prefs?.remove(Constants.KEY_ACCESS_TOKEN); + store.dispatch( + new UpdateCurrentUser(null)); + eventBus.fire( + new OnCurrentUserUpdated()); + Routes.router.navigateTo( + context, '/', replace: true, + clearStack: true); }, ) ], diff --git a/lib/events/events.dart b/lib/events/events.dart index 47126fd..90f1323 100644 --- a/lib/events/events.dart +++ b/lib/events/events.dart @@ -87,7 +87,7 @@ class OnProductWillAddToCart { double price; String description; Business business; - GlobalKey buttonKey; + GlobalKey? buttonKey; OnProductWillAddToCart(this.product, this.selections, this.price, this.description, this.business, {this.buttonKey}); } diff --git a/lib/main.dart b/lib/main.dart index 6981244..e390f36 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,9 +1,4 @@ -import 'dart:async'; - -import 'package:catcher/catcher.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:flutter_wisetronic/pages/buy_service.dart'; @@ -14,12 +9,8 @@ import 'pages/create_online_store_1.dart'; import 'pages/download.dart'; import 'pages/me.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:splashscreen/splashscreen.dart'; -// import 'package:uni_links/uni_links.dart'; import 'constants.dart'; -import 'events/eventbus.dart'; -import 'events/events.dart'; import 'generated/l10n.dart'; import 'pages/home.dart'; import 'pages/plain_page.dart'; @@ -34,20 +25,14 @@ import 'utils/utils.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); - // Enable configureApp will cause route problem. - // configureApp(); setPathUrlStrategy(); runApp(MyApp()); } class MyApp extends StatelessWidget { - String _to = '/'; - MyApp() { Routes.configure(); Utils().init(); - Util().init(); - // getCurrentPosition(); } static getCurrentPosition() async { @@ -95,27 +80,8 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - Widget _buildBody() { - return SplashScreen( - seconds: 5, - routeName: _to, - navigateAfterSeconds: Home(title: Constants.APP_TITLE,), - styleTextUnderTheLoader: new TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20.0, - ), - imageBackground: (Image.network(Constants.BASE_API_URL + 'gallery/get-minimanager-splash/')).image, - backgroundColor: Colors.white, - onClick: () { - - }, - loaderColor: Colors.blue, - ); - } - return MaterialApp( debugShowCheckedModeBanner: Constants.DEBUG, - navigatorKey: kIsWeb ? null : Catcher.navigatorKey, localizationsDelegates: [ GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, @@ -124,20 +90,26 @@ class MyApp extends StatelessWidget { S.delegate, ], supportedLocales: S.delegate.supportedLocales, - localeResolutionCallback: (Locale locale, Iterable supportedLocales) { - print('Language code: ${locale.languageCode}, Country code: ${locale.countryCode}'); - for (final supportedLocale in supportedLocales) { - if (supportedLocale.languageCode == locale.languageCode) { - store.dispatch(UpdateLocale(locale)); - return supportedLocale; + localeResolutionCallback: (Locale? locale, Iterable? supportedLocales) { + print('Language code: ${locale?.languageCode}, Country code: ${locale?.countryCode}'); + if (locale != null && supportedLocales != null) { + for (final supportedLocale in supportedLocales) { + if (supportedLocale.languageCode == locale.languageCode) { + store.dispatch(UpdateLocale(locale)); + return supportedLocale; + } } - } - store.dispatch(UpdateLocale(supportedLocales.first)); + store.dispatch(UpdateLocale(supportedLocales.first)); return supportedLocales.first; + } + return null; }, onGenerateRoute: (RouteSettings settings) { - final List pathElements = settings.name.split('/'); - print('path elements: $pathElements'); + final uri = Uri.parse(settings.name!); + final path = uri.path; + print('path: $path'); + final List pathElements = path.split('/'); + print('path elements --> $pathElements'); if (pathElements[0] != '') { return null; } diff --git a/lib/models/address.dart b/lib/models/address.dart index ffd7ec3..e9ac611 100644 --- a/lib/models/address.dart +++ b/lib/models/address.dart @@ -1,21 +1,21 @@ import 'dart:convert'; class Address { - int id; - String addressLine1; - String addressLine2; - String city; - String state; - String country; - String zip; - String phone; - String fax; - String email; - String contactName; - int gender; - String lat; - String lng; - String fullAddress; + int? id; + String? addressLine1; + String? addressLine2; + String? city; + String? state; + String? country; + String? zip; + String? phone; + String? fax; + String? email; + String? contactName; + int? gender; + String? lat; + String? lng; + String? fullAddress; Address.fromJson(Map json) : id = json['id'], diff --git a/lib/models/business.dart b/lib/models/business.dart index d6e1bd0..44e3584 100644 --- a/lib/models/business.dart +++ b/lib/models/business.dart @@ -58,7 +58,7 @@ class Business { String chaseXLogin; String chaseTransactionKey; String chaseResponseKey; - DistanceInfo distanceInfo; + DistanceInfo? distanceInfo; int commentsCount; bool forceClose; bool isPublic; diff --git a/lib/models/cart_info.dart b/lib/models/cart_info.dart index 4516a53..646e5df 100644 --- a/lib/models/cart_info.dart +++ b/lib/models/cart_info.dart @@ -7,18 +7,18 @@ import 'cart_line_item.dart'; import 'extra_fee.dart'; class CartInfo { - int id; - double originPrice; - double discountPrice; - double totalPrice; - Business businessInfo; - List productList; - List extraFeeList; - List discountList; - int deliveryMethod; - String shippingMethod; - double amountPaid; - String extraData; + int? id; + double? originPrice; + double? discountPrice; + double? totalPrice; + Business? businessInfo; + List? productList; + List? extraFeeList; + List? discountList; + int? deliveryMethod; + String? shippingMethod; + double? amountPaid; + String? extraData; CartInfo.fromJson(Map json) : id = json['id'], @@ -53,7 +53,7 @@ class CartInfo { if (productList == null) { productList = [item]; } else { - productList.add(item); + productList!.add(item); } } @@ -74,19 +74,19 @@ class CartInfo { originPrice = 0.0; discountPrice = 0.0; totalPrice = 0.0; - for (var i = 0; i < productList.length; i++) { - newTotal += productList[i].getTotalPrice(); + for (var i = 0; i < productList!.length; i++) { + newTotal += productList![i].getTotalPrice(); } originPrice = newTotal; totalPrice = newTotal; - return totalPrice; + return totalPrice!; } int getProductListTotalQuantity() { int qty = 0; - if (productList != null && productList.length > 0) { - for (var i = 0; i < productList.length; i++) { - qty += productList[i].quantity.round(); + if (productList != null && productList!.length > 0) { + for (var i = 0; i < productList!.length; i++) { + qty += productList![i].quantity!.round(); } } return qty; diff --git a/lib/models/cart_line_item.dart b/lib/models/cart_line_item.dart index 5adb0ec..6e31cea 100644 --- a/lib/models/cart_line_item.dart +++ b/lib/models/cart_line_item.dart @@ -6,15 +6,15 @@ import 'package:uuid/uuid.dart'; import 'product.dart'; class CartLineItem { - int id; - double unitPrice; - double totalPrice; - Product product; - String name; - String description; - double quantity; - String uuid; - String parentUuid; + int? id; + double? unitPrice; + double? totalPrice; + Product? product; + String? name; + String? description; + double? quantity; + String? uuid; + String? parentUuid; CartLineItem() { uuid = Uuid().v4(); @@ -48,7 +48,7 @@ class CartLineItem { } double getTotalPrice() { - totalPrice = unitPrice * quantity; - return totalPrice; + totalPrice = unitPrice! * quantity!; + return totalPrice!; } } \ No newline at end of file diff --git a/lib/models/coupon.dart b/lib/models/coupon.dart index 45ac37b..95d6012 100644 --- a/lib/models/coupon.dart +++ b/lib/models/coupon.dart @@ -9,7 +9,7 @@ class Coupon { String description; String expirationDate; double minAmount; - Business store; + Business? store; double valueAmount; bool isPercentage; diff --git a/lib/models/distance_info.dart b/lib/models/distance_info.dart index 96cad60..2a6ca6f 100644 --- a/lib/models/distance_info.dart +++ b/lib/models/distance_info.dart @@ -4,9 +4,9 @@ import 'dart:convert'; import 'text_value.dart'; class DistanceInfo { - TextValue duration; - TextValue distance; - String status; + TextValue? duration; + TextValue? distance; + String? status; DistanceInfo.fromJson(Map json) : duration = json['duration'] != null ? TextValue.fromJson(json['duration']) : null, diff --git a/lib/models/order.dart b/lib/models/order.dart index 9528d3b..e48f08f 100644 --- a/lib/models/order.dart +++ b/lib/models/order.dart @@ -14,8 +14,8 @@ class Order { int id; int userId; int businessId; - Business businessInfo; - CartInfo cartInfo; + Business? businessInfo; + CartInfo? cartInfo; int status; double originPrice; double discountPrice; @@ -23,7 +23,7 @@ class Order { String consignee; String phone; String address; - Address shippingAddress; + Address? shippingAddress; int payMethod; String remark; String orderNum; @@ -33,11 +33,11 @@ class Order { String paymentStatus; // UNPAID, PAID, PARTIALPAID double amountPaid; List fulfillments; - String extraData; + String? extraData; bool hasComment; double fee; UserPosition shipperPosition; - DistanceInfo deliveryDistance; + DistanceInfo? deliveryDistance; Order.fromJson(Map json) : id = json['id'], @@ -100,8 +100,10 @@ class Order { double getSubtotal() { double subtotal = 0.0; - for (CartLineItem lineItem in cartInfo.productList) { - subtotal += lineItem.getTotalPrice(); + if (cartInfo != null) { + for (CartLineItem lineItem in cartInfo!.productList!) { + subtotal += lineItem.getTotalPrice(); + } } return subtotal; } diff --git a/lib/models/payment_platform.dart b/lib/models/payment_platform.dart index 5395030..bc1acea 100644 --- a/lib/models/payment_platform.dart +++ b/lib/models/payment_platform.dart @@ -6,19 +6,19 @@ import 'package:flutter/cupertino.dart'; import '../generated/l10n.dart'; class PaymentPlatform { - int id; - String name; - String code; - String method; - String icon; - String xLogin; - String transactionKey; - String responseKey; - String squareAppId; - String squareAccessToken; - String squareLocationId; - String publishableKey; - String merchantId; + int? id; + String? name; + String? code; + String? method; + String? icon; + String? xLogin; + String? transactionKey; + String? responseKey; + String? squareAppId; + String? squareAccessToken; + String? squareLocationId; + String? publishableKey; + String? merchantId; PaymentPlatform(this.code); @@ -57,16 +57,12 @@ class PaymentPlatform { switch(code) { case 'chase': return S.of(context).credit_debit_card; - break; case 'web-credit-card': return S.of(context).credit_card; - break; case 'ALIPAY': return S.of(context).alipay; - break; case 'WECHATPAY': return S.of(context).wechatpay; - break; case 'paypal': return S.of(context).paypal; case 'payondeliverypickup': diff --git a/lib/models/position.dart b/lib/models/position.dart index 96a202e..7a8017d 100644 --- a/lib/models/position.dart +++ b/lib/models/position.dart @@ -3,7 +3,7 @@ class Position { final double latitude; final double longitude; - Position({this.latitude, this.longitude}); + Position({required this.latitude, required this.longitude}); @override bool operator ==(other) { diff --git a/lib/models/product.dart b/lib/models/product.dart index e7ca4d8..049e6e2 100644 --- a/lib/models/product.dart +++ b/lib/models/product.dart @@ -5,23 +5,23 @@ import 'Subproduct.dart'; import 'product_attribute.dart'; class Product { - int id; - int businessId; - int categoryId; - String name; - double price; - double regularPrice; - String description; - String detailDescription; - String imagePath; - String secondImagePath; - double monthSales; - int rate; - double leftNum; - List productAttributes; - bool nonInventory; - String extraData; - List subproducts; + int? id; + int? businessId; + int? categoryId; + String? name; + double? price; + double? regularPrice; + String? description; + String? detailDescription; + String? imagePath; + String? secondImagePath; + double? monthSales; + int? rate; + double? leftNum; + List? productAttributes; + bool? nonInventory; + String? extraData; + List? subproducts; Product(int id, int businessId, String name, double price, String description, String imagePath, List productAttributes) { diff --git a/lib/models/product_attribute.dart b/lib/models/product_attribute.dart index e519a4d..eda6468 100644 --- a/lib/models/product_attribute.dart +++ b/lib/models/product_attribute.dart @@ -10,7 +10,7 @@ class ProductAttribute { bool singleSelection; bool byQuantity; bool required; - String extra; + String? extra; bool disabled; ProductAttribute.fromJson(Map json) diff --git a/lib/models/waiting_line.dart b/lib/models/waiting_line.dart index dc1dffa..baccc69 100644 --- a/lib/models/waiting_line.dart +++ b/lib/models/waiting_line.dart @@ -4,8 +4,8 @@ import 'dart:convert'; import 'waiting_line_item.dart'; class WaitingLine { - List waitingLines; - String storeSn; + List? waitingLines; + String? storeSn; WaitingLine.fromJson(Map json) : waitingLines = (json['waiting_lines'] as List).map((i) => WaitingLineItem.fromJson(i)).toList(), diff --git a/lib/pages/attribute_selection.dart b/lib/pages/attribute_selection.dart index a977d1a..1bf4afb 100644 --- a/lib/pages/attribute_selection.dart +++ b/lib/pages/attribute_selection.dart @@ -8,19 +8,16 @@ import '../models/product.dart'; class AttributeSelection extends StatelessWidget { final Product product; final Business business; - final GlobalKey startKey; + final GlobalKey? startKey; - const AttributeSelection({Key key, this.product, this.business, this.startKey}) : super(key: key); + const AttributeSelection({Key? key, required this.product, required this.business, this.startKey}) : super(key: key); @override Widget build(BuildContext context) { - return ResponsiveBuilder( - builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileAttributeSelection(product: product, business: business, startKey: startKey,), - tablet: MobileAttributeSelection(product: product, business: business, startKey: startKey,), - desktop: MobileAttributeSelection(product: product, business: business, startKey: startKey,), - ), + return ScreenTypeLayout.builder( + mobile: (context) => MobileAttributeSelection(product: product, business: business, startKey: startKey), + tablet: (context) => MobileAttributeSelection(product: product, business: business, startKey: startKey), + desktop: (context) => MobileAttributeSelection(product: product, business: business, startKey: startKey), ); } diff --git a/lib/pages/blog.dart b/lib/pages/blog.dart index 8ef70ef..5a057e0 100644 --- a/lib/pages/blog.dart +++ b/lib/pages/blog.dart @@ -8,24 +8,20 @@ import '../widgets/desktop/desktop_blog.dart'; import '../widgets/mobile/mobile_blog.dart'; class Blog extends StatelessWidget { - final Key key; final int businessId; - const Blog({this.key, int businessId}) : + const Blog({Key? key, required int businessId}) : businessId = businessId ?? Constants.BUSINESS_ID; @override Widget build(BuildContext context) { - return ResponsiveBuilder( - builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileBlog(businessId: businessId,), - tablet: DesktopBlog(businessId: businessId,), - desktop: Scrollbar( - isAlwaysShown: true, - child: DesktopBlog(businessId: businessId,), - ), - ), + return ScreenTypeLayout.builder( + mobile: (context) => MobileBlog(businessId: businessId), + tablet: (context) => DesktopBlog(businessId: businessId), + desktop: (context) => Scrollbar( + thumbVisibility: true, + child: DesktopBlog(businessId: businessId), + ), ); } diff --git a/lib/pages/buy_service.dart b/lib/pages/buy_service.dart index 3205867..afb49d1 100644 --- a/lib/pages/buy_service.dart +++ b/lib/pages/buy_service.dart @@ -19,10 +19,10 @@ import '../widgets/mobile/mobile_renew_license.dart'; class BuyService extends StatefulWidget { final int gid; final String serviceName; - final String domain; - final int sid; + final String? domain; + final int? sid; - const BuyService(this.gid, this.serviceName, {Key key, this.domain, this.sid = 0}) : + const BuyService(this.gid, this.serviceName, {Key? key, this.domain, this.sid = 0}) : super(key: key); @override @@ -30,7 +30,7 @@ class BuyService extends StatefulWidget { } class BuyServiceState extends State { - Map data; + Map? data; @override Widget build(BuildContext context) { @@ -48,13 +48,10 @@ class BuyServiceState extends State { ); } - return ResponsiveBuilder( - builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileBuyService(data), - tablet: DesktopBuyService(data), - desktop: DesktopBuyService(data), - ), + return ScreenTypeLayout.builder( + mobile: (context) => MobileBuyService(data), + tablet: (context) => DesktopBuyService(data), + desktop: (context) => DesktopBuyService(data), ); } @@ -73,7 +70,7 @@ class BuyServiceState extends State { } ).then((value) { data = value; - data['domain'] = widget.domain; + data?['domain'] = widget.domain; print('data: $data'); setState(() {}); }).onError((error, stackTrace) { diff --git a/lib/pages/change_mobile_or_email.dart b/lib/pages/change_mobile_or_email.dart index 63ec9c7..1be62df 100644 --- a/lib/pages/change_mobile_or_email.dart +++ b/lib/pages/change_mobile_or_email.dart @@ -15,7 +15,7 @@ import '../widgets/mobile/mobile_change_mobile_or_email.dart'; class ChangeMobileOrEmail extends StatelessWidget { final bool isMobile; - const ChangeMobileOrEmail(this.isMobile, {Key key}) : super(key: key); + const ChangeMobileOrEmail(this.isMobile, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -31,15 +31,15 @@ class ChangeMobileOrEmail extends StatelessWidget { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileChangeMobileOrEmail(isMobile), - tablet: DesktopChangeMobileOrEmail(isMobile), - desktop: DesktopChangeMobileOrEmail(isMobile), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileChangeMobileOrEmail(isMobile), + tablet: (context) => DesktopChangeMobileOrEmail(isMobile), + desktop: (context) => DesktopChangeMobileOrEmail(isMobile), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/change_password.dart b/lib/pages/change_password.dart index df4f8a3..ea8c3db 100644 --- a/lib/pages/change_password.dart +++ b/lib/pages/change_password.dart @@ -29,15 +29,15 @@ class ChangePassword extends StatelessWidget { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileChangePassword(), - tablet: DesktopChangePassword(), - desktop: DesktopChangePassword(), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileChangePassword(), + tablet: (context) => DesktopChangePassword(), + desktop: (context) => DesktopChangePassword(), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/checkout.dart b/lib/pages/checkout.dart index da5f521..6a58726 100644 --- a/lib/pages/checkout.dart +++ b/lib/pages/checkout.dart @@ -11,7 +11,7 @@ import '../widgets/mobile/mobile_checkout.dart'; class Checkout extends StatelessWidget { final int businessId; - const Checkout(this.businessId, {Key key}) : + const Checkout(this.businessId, {Key? key}) : super(key: key); @override @@ -20,10 +20,10 @@ class Checkout extends StatelessWidget { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileCheckout(businessId), - tablet: DesktopCheckout(businessId), - desktop: DesktopCheckout(businessId), + ScreenTypeLayout.builder( + mobile: (context) => MobileCheckout(businessId), + tablet: (context) => DesktopCheckout(businessId), + desktop: (context) => DesktopCheckout(businessId), ), ); } diff --git a/lib/pages/contact_us.dart b/lib/pages/contact_us.dart index 1d67451..496113b 100644 --- a/lib/pages/contact_us.dart +++ b/lib/pages/contact_us.dart @@ -14,7 +14,7 @@ import '../widgets/mobile/mobile_contact_us.dart'; class ContactUs extends StatefulWidget { final int businessId; - const ContactUs({this.businessId, Key key}) : + const ContactUs({required this.businessId, Key? key}) : super(key: key); @override @@ -22,7 +22,7 @@ class ContactUs extends StatefulWidget { } class ContactUsState extends State { - Business business; + Business? business; @override Widget build(BuildContext context) { @@ -42,10 +42,10 @@ class ContactUsState extends State { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileContactUs(business), - tablet: DesktopContactUs(business), - desktop: DesktopContactUs(business), + ScreenTypeLayout.builder( + mobile: (context) => MobileContactUs(business!), + tablet: (context) => DesktopContactUs(business!), + desktop: (context) => DesktopContactUs(business!), ), ); } diff --git a/lib/pages/coupons.dart b/lib/pages/coupons.dart index 666cb4d..7ac5c0e 100644 --- a/lib/pages/coupons.dart +++ b/lib/pages/coupons.dart @@ -10,7 +10,7 @@ import '../widgets/mobile/mobile_coupons.dart'; class Coupons extends StatelessWidget { final int contactId; - const Coupons(this.contactId, {Key key}) : + const Coupons(this.contactId, {Key? key}) : super(key: key); @@ -20,10 +20,10 @@ class Coupons extends StatelessWidget { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileCoupons(contactId,), - tablet: DesktopCoupons(contactId,), - desktop: DesktopCoupons(contactId,), + ScreenTypeLayout.builder( + mobile: (context) => MobileCoupons(contactId,), + tablet: (context) => DesktopCoupons(contactId,), + desktop: (context) => DesktopCoupons(contactId,), ), ); } diff --git a/lib/pages/create_online_store_1.dart b/lib/pages/create_online_store_1.dart index f4f600f..f631440 100644 --- a/lib/pages/create_online_store_1.dart +++ b/lib/pages/create_online_store_1.dart @@ -11,7 +11,7 @@ import '../widgets/mobile/create_online_store_1.dart' as mobile; class CreateOnlineStore1 extends StatefulWidget { - const CreateOnlineStore1({Key key}) : + const CreateOnlineStore1({Key? key}) : super(key: key); @override @@ -33,10 +33,10 @@ class CreateOnlineStore1State extends State { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: mobile.CreateOnlineStore1(Constants.BUSINESS_ID), - tablet: desktop.CreateOnlineStore1(Constants.BUSINESS_ID), - desktop: desktop.CreateOnlineStore1(Constants.BUSINESS_ID), + ScreenTypeLayout.builder( + mobile: (context) => mobile.CreateOnlineStore1(Constants.BUSINESS_ID), + tablet: (context) => desktop.CreateOnlineStore1(Constants.BUSINESS_ID), + desktop: (context) => desktop.CreateOnlineStore1(Constants.BUSINESS_ID), ), ); } diff --git a/lib/pages/download.dart b/lib/pages/download.dart index e72f259..6673a5b 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; + Map? data; @override Widget build(BuildContext context) { @@ -57,18 +57,18 @@ class DownloadState extends State { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? MobileNavigationDrawer() : null, - body: ScreenTypeLayout( - mobile: MobileDownloadApps(data), - tablet: DesktopDownloadApps(data), - desktop: Scrollbar( - isAlwaysShown: true, - child: DesktopDownloadApps(data), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileDownloadApps(data!), + tablet: (context) => DesktopDownloadApps(data!), + desktop: (context) => Scrollbar( + thumbVisibility: true, + child: DesktopDownloadApps(data!), ), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); @@ -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/edit_address.dart b/lib/pages/edit_address.dart index 3324ae9..08bf07e 100644 --- a/lib/pages/edit_address.dart +++ b/lib/pages/edit_address.dart @@ -13,20 +13,19 @@ import '../widgets/general/navigationbar.dart'; import '../widgets/mobile/MobileBottomNav.dart'; class EditAddress extends StatelessWidget { - final Key key; - final Address address; - final int businessId; - const EditAddress(this.address, {this.key, int businessId}) : + final Address? address; + final int? businessId; + const EditAddress(this.address, {Key? key, int? businessId}) : businessId = businessId ?? Constants.BUSINESS_ID; @override Widget build(BuildContext context) { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileEditAddress(address, businessId: businessId,), - tablet: DesktopEditAddress(address, businessId: businessId,), - desktop: DesktopEditAddress(address, businessId: businessId,), + ScreenTypeLayout.builder( + mobile: (context) => MobileEditAddress(address, businessId: businessId,), + tablet: (context) => DesktopEditAddress(address, businessId: businessId,), + desktop: (context) => DesktopEditAddress(address, businessId: businessId,), ), ); } diff --git a/lib/pages/forgot_password.dart b/lib/pages/forgot_password.dart index 7542cc1..087b1f9 100644 --- a/lib/pages/forgot_password.dart +++ b/lib/pages/forgot_password.dart @@ -12,7 +12,7 @@ import '../widgets/general/navigationbar.dart'; import '../widgets/mobile/MobileBottomNav.dart'; class ForgotPassword extends StatelessWidget { - const ForgotPassword({Key key}) : super(key: key); + const ForgotPassword({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -28,15 +28,15 @@ class ForgotPassword extends StatelessWidget { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileForgotPassword(), - tablet: DesktopForgotPassword(), - desktop: DesktopForgotPassword(), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileForgotPassword(), + tablet: (context) => DesktopForgotPassword(), + desktop: (context) => DesktopForgotPassword(), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/home.dart b/lib/pages/home.dart index 3399f81..6b780fa 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -34,7 +34,7 @@ import '../widgets/mobile/mobile_navigation_drawer.dart'; class Home extends StatefulWidget { final String title; - Home({Key key, this.title = ''}) : super(key: key); + Home({Key? key, this.title = ''}) : super(key: key); @override State createState() { @@ -46,11 +46,11 @@ class Home extends StatefulWidget { class HomeState extends State { final _scaffoldKey = GlobalKey(); List galleries = []; - String content1Message; - Map content2; + String? content1Message; + Map? content2; - StreamSubscription _sub; - Uri _latestUri; + StreamSubscription? _sub; + Uri? _latestUri; @override Widget build(BuildContext context) { @@ -74,8 +74,8 @@ class HomeState extends State { appBar: MiniNavigationBar(), drawer: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? MobileNavigationDrawer() : null, body: DoubleBackToCloseAppWrapper( - child: ScreenTypeLayout( - mobile: SingleChildScrollView( + child: ScreenTypeLayout.builder( + mobile: (context) => SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -86,7 +86,7 @@ class HomeState extends State { ], ), ), - tablet: SingleChildScrollView( + tablet: (context) => SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -98,8 +98,8 @@ class HomeState extends State { ], ), ), - desktop: Scrollbar( - isAlwaysShown: true, + desktop: (context) => Scrollbar( + thumbVisibility: true, child: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, @@ -115,10 +115,10 @@ class HomeState extends State { ), ), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); @@ -136,7 +136,7 @@ class HomeState extends State { _loadData(); eventBus.on().listen((event) { if (mounted) { - _scaffoldKey.currentState.openDrawer(); + _scaffoldKey.currentState?.openDrawer(); } }); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { @@ -163,7 +163,9 @@ class HomeState extends State { if (!mounted) return; _latestUri = Uri.base; print('uri base $_latestUri'); - eventBus.fire(OnGotDeepLinkUri(_latestUri)); + if (_latestUri != null) { + eventBus.fire(OnGotDeepLinkUri(_latestUri!)); + } } else { // _sub = getUriLinksStream().listen((Uri uri) { // print('_sub should get uri $uri'); diff --git a/lib/pages/igoshow_learn_more.dart b/lib/pages/igoshow_learn_more.dart index 8be0e9b..c131789 100644 --- a/lib/pages/igoshow_learn_more.dart +++ b/lib/pages/igoshow_learn_more.dart @@ -16,7 +16,7 @@ import '../widgets/mobile/MobileBottomNav.dart'; import '../widgets/mobile/mobile_igoshow_learn_more.dart'; class IGoShowLearnMore extends StatefulWidget { - const IGoShowLearnMore({Key key}) : super(key: key); + const IGoShowLearnMore({Key? key}) : super(key: key); @override State createState() { @@ -26,7 +26,7 @@ class IGoShowLearnMore extends StatefulWidget { class IGoShowLearnMoreState extends State { final _scaffoldKey = GlobalKey(); - Map data; + Map? data; @override Widget build(BuildContext context) { @@ -55,15 +55,15 @@ class IGoShowLearnMoreState extends State { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileiGoShowLearnMore(data), - tablet: DesktopiGoShowLearnMore(data), - desktop: DesktopiGoShowLearnMore(data), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileiGoShowLearnMore(data!), + tablet: (context) => DesktopiGoShowLearnMore(data!), + desktop: (context) => DesktopiGoShowLearnMore(data!), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/login.dart b/lib/pages/login.dart index 6b18ab7..199661e 100644 --- a/lib/pages/login.dart +++ b/lib/pages/login.dart @@ -14,9 +14,7 @@ import '../widgets/mobile/MobileBottomNav.dart'; import '../widgets/mobile/mobile_login.dart'; class Login extends StatefulWidget { - final Key key; - - const Login({this.key}) : super(key: key); + const Login({Key? key}) : super(key: key); @override State createState() { @@ -50,15 +48,15 @@ class LoginState extends State { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileLogin(), - tablet: DesktopLogin(), - desktop: DesktopLogin(), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileLogin(), + tablet: (context) => DesktopLogin(), + desktop: (context) => DesktopLogin(), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/me.dart b/lib/pages/me.dart index 39c8a7a..65814b4 100644 --- a/lib/pages/me.dart +++ b/lib/pages/me.dart @@ -15,9 +15,7 @@ import '../widgets/mobile/MobileBottomNav.dart'; import '../widgets/mobile/mobile_me.dart'; class Me extends StatefulWidget { - final Key key; - - const Me({this.key}) : super(key: key); + const Me({Key? key}) : super(key: key); @override State createState() { @@ -52,16 +50,16 @@ class MeState extends State { ), drawer: null, body: DoubleBackToCloseAppWrapper( - child: ScreenTypeLayout( - mobile: MobileMe(), - tablet: DesktopMe(), - desktop: DesktopMe(), + child: ScreenTypeLayout.builder( + mobile: (context) => MobileMe(), + tablet: (context) => DesktopMe(), + desktop: (context) => DesktopMe(), ), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 3,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 3,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/minipos_learn_more.dart b/lib/pages/minipos_learn_more.dart index a6d886a..1aea5f7 100644 --- a/lib/pages/minipos_learn_more.dart +++ b/lib/pages/minipos_learn_more.dart @@ -16,7 +16,7 @@ import '../widgets/mobile/MobileBottomNav.dart'; import '../widgets/mobile/mobile_minipos_learn_more.dart'; class MiniPosLearnMore extends StatefulWidget { - const MiniPosLearnMore({Key key}) : super(key: key); + const MiniPosLearnMore({Key? key}) : super(key: key); @override State createState() { @@ -26,7 +26,7 @@ class MiniPosLearnMore extends StatefulWidget { class MiniPosLearnMoreState extends State { final _scaffoldKey = GlobalKey(); - Map data; + Map? data; @override Widget build(BuildContext context) { @@ -42,35 +42,36 @@ class MiniPosLearnMoreState extends State { ); } - return WillPopScope( - child: ResponsiveBuilder( - builder: (context, sizingInformation) => - Scaffold( - key: _scaffoldKey, - appBar: MiniNavigationBar( - title: S.of(context).minipos, - back: true, - breadCrumbs: [ - BreadCrumb(S.of(context).minipos, null), - ], - breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, - ), - drawer: null, - body: ScreenTypeLayout( - mobile: MobileMiniPosLearnMore(data), - tablet: DesktopMiniPosLearnMore(data), - desktop: DesktopMiniPosLearnMore(data), - ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), - ), + return ResponsiveBuilder( + builder: (context, sizingInformation) => PopScope( + canPop: true, + onPopInvokedWithResult: (didPop, result) { + if (didPop) return; + // 可以在这里处理返回逻辑 + }, + child: Scaffold( + key: _scaffoldKey, + appBar: MiniNavigationBar( + title: S.of(context).minipos, + back: true, + breadCrumbs: [ + BreadCrumb(S.of(context).minipos, null), + ], + breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), + drawer: null, + body: ScreenTypeLayout.builder( + mobile: (context) => MobileMiniPosLearnMore(data!), + tablet: (context) => DesktopMiniPosLearnMore(data!), + desktop: (context) => DesktopMiniPosLearnMore(data!), + ), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), + ), + ), ), - onWillPop: () async { - return true; - }, ); } diff --git a/lib/pages/my_addresses.dart b/lib/pages/my_addresses.dart index 70967de..b247659 100644 --- a/lib/pages/my_addresses.dart +++ b/lib/pages/my_addresses.dart @@ -8,20 +8,19 @@ import '../widgets/desktop/desktop_my_addresses.dart'; import '../widgets/mobile/mobile_my_addresses.dart'; class MyAddresses extends StatelessWidget { - final Key key; final int businessId; - const MyAddresses({this.key, int businessId}) : + const MyAddresses({Key? key, int? businessId}) : businessId = businessId ?? Constants.BUSINESS_ID; @override Widget build(BuildContext context) { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileMyAddresses(businessId: businessId,), - tablet: DesktopMyAddresses(businessId: businessId,), - desktop: DesktopMyAddresses(businessId: businessId,), + ScreenTypeLayout.builder( + mobile: (context) => MobileMyAddresses(businessId: businessId,), + tablet: (context) => DesktopMyAddresses(businessId: businessId,), + desktop: (context) => DesktopMyAddresses(businessId: businessId,), ), ); } diff --git a/lib/pages/my_cards.dart b/lib/pages/my_cards.dart index 6fe1405..832afd4 100644 --- a/lib/pages/my_cards.dart +++ b/lib/pages/my_cards.dart @@ -35,10 +35,10 @@ class MyCards extends StatelessWidget { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileMyCards(), - tablet: DesktopMyCards(), - desktop: DesktopMyCards(), + ScreenTypeLayout.builder( + mobile: (context) => MobileMyCards(), + tablet: (context) => DesktopMyCards(), + desktop: (context) => DesktopMyCards(), ), ); } diff --git a/lib/pages/my_support.dart b/lib/pages/my_support.dart index 908b3d2..ac9d360 100644 --- a/lib/pages/my_support.dart +++ b/lib/pages/my_support.dart @@ -8,20 +8,19 @@ import '../widgets/desktop/desktop_my_support.dart'; import '../widgets/mobile/mobile_my_support.dart'; class MySupport extends StatelessWidget { - final Key key; final int businessId; - const MySupport({this.key, int businessId}) : + const MySupport({Key? key, int? businessId}) : businessId = businessId ?? Constants.BUSINESS_ID; @override Widget build(BuildContext context) { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileMySupport(businessId: businessId,), - tablet: DesktopMySupport(businessId: businessId,), - desktop: DesktopMySupport(businessId: businessId,), + ScreenTypeLayout.builder( + mobile: (context) => MobileMySupport(businessId: businessId,), + tablet: (context) => DesktopMySupport(businessId: businessId,), + desktop: (context) => DesktopMySupport(businessId: businessId,), ), ); } diff --git a/lib/pages/new_address.dart b/lib/pages/new_address.dart index 08044cf..79259e6 100644 --- a/lib/pages/new_address.dart +++ b/lib/pages/new_address.dart @@ -7,25 +7,24 @@ import '../widgets/desktop/desktop_new_address.dart'; import '../widgets/mobile/mobile_new_address.dart'; class NewAddress extends StatelessWidget { - final Key key; - final LocatedAddress locatedAddress; - final int businessId; - const NewAddress({this.key, this.locatedAddress, this.businessId}) : super(key: key); + final LocatedAddress? locatedAddress; + final int? businessId; + const NewAddress({Key? key, this.locatedAddress, this.businessId}) : super(key: key); @override Widget build(BuildContext context) { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileNewAddress( + ScreenTypeLayout.builder( + mobile: (context) => MobileNewAddress( locatedAddress: locatedAddress, businessId: businessId, ), - tablet: DesktopNewAddress( + tablet: (context) => DesktopNewAddress( locatedAddress: locatedAddress, businessId: businessId, ), - desktop: DesktopNewAddress( + desktop: (context) => DesktopNewAddress( locatedAddress: locatedAddress, businessId: businessId, ), diff --git a/lib/pages/new_comment.dart b/lib/pages/new_comment.dart index 1770d87..4f468e0 100644 --- a/lib/pages/new_comment.dart +++ b/lib/pages/new_comment.dart @@ -10,7 +10,7 @@ import '../widgets/mobile/mobile_new_comment.dart'; class NewComment extends StatelessWidget { final int orderId; - const NewComment(this.orderId, {Key key}) : + const NewComment(this.orderId, {Key? key}) : super(key: key); @@ -20,10 +20,10 @@ class NewComment extends StatelessWidget { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileNewComment(orderId,), - tablet: DesktopNewComment(orderId,), - desktop: DesktopNewComment(orderId,), + ScreenTypeLayout.builder( + mobile: (context) => MobileNewComment(orderId,), + tablet: (context) => DesktopNewComment(orderId,), + desktop: (context) => DesktopNewComment(orderId,), ), ); } diff --git a/lib/pages/new_ticket.dart b/lib/pages/new_ticket.dart index 064d4c8..9685b8a 100644 --- a/lib/pages/new_ticket.dart +++ b/lib/pages/new_ticket.dart @@ -14,10 +14,9 @@ import '../widgets/mobile/MobileBottomNav.dart'; import '../widgets/mobile/mobile_new_ticket.dart'; class NewTicket extends StatefulWidget { - final Key key; - final int businessId; + final int? businessId; - const NewTicket({this.key, int businessId}) : + const NewTicket({Key? key, int? businessId}) : businessId = businessId ?? Constants.BUSINESS_ID; @override @@ -52,15 +51,15 @@ class NewTicketState extends State { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileNewTicket(businessId: widget.businessId,), - tablet: DesktopNewTicket(businessId: widget.businessId,), - desktop: DesktopNewTicket(businessId: widget.businessId,), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileNewTicket(businessId: widget.businessId!,), + tablet: (context) => DesktopNewTicket(businessId: widget.businessId!,), + desktop: (context) => DesktopNewTicket(businessId: widget.businessId!,), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/new_user.dart b/lib/pages/new_user.dart index dae15d2..a24ae9d 100644 --- a/lib/pages/new_user.dart +++ b/lib/pages/new_user.dart @@ -12,7 +12,7 @@ import '../widgets/mobile/MobileBottomNav.dart'; import '../widgets/mobile/mobile_new_user.dart'; class NewUser extends StatelessWidget { - const NewUser({Key key}) : super(key: key); + const NewUser({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -28,15 +28,15 @@ class NewUser extends StatelessWidget { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileNewUser(), - tablet: DesktopNewUser(), - desktop: DesktopNewUser(), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileNewUser(), + tablet: (context) => DesktopNewUser(), + desktop: (context) => DesktopNewUser(), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/order_detail.dart b/lib/pages/order_detail.dart index 40d9a6a..64c5222 100644 --- a/lib/pages/order_detail.dart +++ b/lib/pages/order_detail.dart @@ -11,7 +11,7 @@ class OrderDetail extends StatelessWidget { final int orderId; final bool fromOrders; - const OrderDetail(this.orderId, {this.fromOrders = false, Key key}) : + const OrderDetail(this.orderId, {this.fromOrders = false, Key? key}) : super(key: key); @override @@ -20,10 +20,10 @@ class OrderDetail extends StatelessWidget { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileOrderDetail(orderId, fromOrders: fromOrders,), - tablet: DesktopOrderDetail(orderId, fromOrders: fromOrders,), - desktop: DesktopOrderDetail(orderId, fromOrders: fromOrders,), + ScreenTypeLayout.builder( + mobile: (context) => MobileOrderDetail(orderId, fromOrders: fromOrders,), + tablet: (context) => DesktopOrderDetail(orderId, fromOrders: fromOrders,), + desktop: (context) => DesktopOrderDetail(orderId, fromOrders: fromOrders,), ), ); } diff --git a/lib/pages/pay_now.dart b/lib/pages/pay_now.dart index 6096f33..063f488 100644 --- a/lib/pages/pay_now.dart +++ b/lib/pages/pay_now.dart @@ -10,7 +10,7 @@ import '../widgets/mobile/mobile_pay_now.dart'; class PayNow extends StatelessWidget { final int orderId; - const PayNow(this.orderId, {Key key}) : + const PayNow(this.orderId, {Key? key}) : super(key: key); @@ -20,10 +20,10 @@ class PayNow extends StatelessWidget { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobilePayNow(orderId,), - tablet: DesktopPayNow(orderId,), - desktop: DesktopPayNow(orderId,), + ScreenTypeLayout.builder( + mobile: (context) => MobilePayNow(orderId,), + tablet: (context) => DesktopPayNow(orderId,), + desktop: (context) => DesktopPayNow(orderId,), ), ); } diff --git a/lib/pages/plain_page.dart b/lib/pages/plain_page.dart index 5fc2a1b..5372cb6 100644 --- a/lib/pages/plain_page.dart +++ b/lib/pages/plain_page.dart @@ -13,9 +13,9 @@ import '../utils/utils.dart'; class PlainPage extends StatefulWidget { final int businessId; - final String slug; + final String? slug; - const PlainPage(this.slug, {this.businessId, Key key}) : + const PlainPage(this.slug, {required this.businessId, Key? key}) : super(key: key); @override @@ -23,7 +23,7 @@ class PlainPage extends StatefulWidget { } class PlainPageState extends State { - Blog blog; + Blog? blog; @override Widget build(BuildContext context) { @@ -43,10 +43,10 @@ class PlainPageState extends State { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobilePlainPage(blog), - tablet: DesktopPlainPage(blog), - desktop: DesktopPlainPage(blog), + ScreenTypeLayout.builder( + mobile: (context) => MobilePlainPage(blog!), + tablet: (context) => DesktopPlainPage(blog!), + desktop: (context) => DesktopPlainPage(blog!), ), ); } diff --git a/lib/pages/product_detail_page.dart b/lib/pages/product_detail_page.dart index 995b755..5be60bd 100644 --- a/lib/pages/product_detail_page.dart +++ b/lib/pages/product_detail_page.dart @@ -13,7 +13,7 @@ class ProductDetailPage extends StatelessWidget { final Business business; final Product product; - const ProductDetailPage({this.business, this.product, Key key}) : + const ProductDetailPage({required this.business, required this.product, Key? key}) : super(key: key); @@ -23,10 +23,10 @@ class ProductDetailPage extends StatelessWidget { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileProductDetailPage(business: business, product: product,), - tablet: DesktopProductDetailPage(business: business, product: product,), - desktop: DesktopProductDetailPage(business: business, product: product,), + ScreenTypeLayout.builder( + mobile: (context) => MobileProductDetailPage(business: business, product: product,), + tablet: (context) => DesktopProductDetailPage(business: business, product: product,), + desktop: (context) => DesktopProductDetailPage(business: business, product: product,), ), ); } diff --git a/lib/pages/product_search.dart b/lib/pages/product_search.dart index 408c4b0..6a7a50c 100644 --- a/lib/pages/product_search.dart +++ b/lib/pages/product_search.dart @@ -9,16 +9,16 @@ import '../widgets/mobile/product_search.dart' as mobile; class ProductSearch extends StatelessWidget { final Business business; - const ProductSearch(this.business, {Key key}) : super(key: key); + const ProductSearch(this.business, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: mobile.ProductSearch(business), - tablet: desktop.ProductSearch(business), - desktop: desktop.ProductSearch(business), + ScreenTypeLayout.builder( + mobile: (context) => mobile.ProductSearch(business), + tablet: (context) => desktop.ProductSearch(business), + desktop: (context) => desktop.ProductSearch(business), ), ); } diff --git a/lib/pages/renew_license.dart b/lib/pages/renew_license.dart index 0a7d395..2df6507 100644 --- a/lib/pages/renew_license.dart +++ b/lib/pages/renew_license.dart @@ -12,7 +12,7 @@ import '../widgets/mobile/mobile_renew_license.dart'; class RenewLicense extends StatefulWidget { - const RenewLicense({Key key}) : + const RenewLicense({Key? key}) : super(key: key); @override @@ -28,10 +28,10 @@ class RenewLicenseState extends State { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileRenewLicense(Constants.BUSINESS_ID), - tablet: DesktopRenewLicense(Constants.BUSINESS_ID), - desktop: DesktopRenewLicense(Constants.BUSINESS_ID), + ScreenTypeLayout.builder( + mobile: (context) => MobileRenewLicense(Constants.BUSINESS_ID), + tablet: (context) => DesktopRenewLicense(Constants.BUSINESS_ID), + desktop: (context) => DesktopRenewLicense(Constants.BUSINESS_ID), ), ); } diff --git a/lib/pages/renew_minioffice.dart b/lib/pages/renew_minioffice.dart index c9b4c34..7cdb0a1 100644 --- a/lib/pages/renew_minioffice.dart +++ b/lib/pages/renew_minioffice.dart @@ -17,7 +17,7 @@ import '../widgets/mobile/mobile_renew_license.dart'; class RenewMiniOffice extends StatefulWidget { final int gid; - const RenewMiniOffice(this.gid, {Key key}) : + const RenewMiniOffice(this.gid, {Key? key}) : super(key: key); @override @@ -25,7 +25,7 @@ class RenewMiniOffice extends StatefulWidget { } class RenewMiniOfficeState extends State { - Map data; + Map? data; @override Widget build(BuildContext context) { @@ -45,10 +45,10 @@ class RenewMiniOfficeState extends State { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileRenewMiniOffice(data), - tablet: DesktopRenewMiniOffice(data), - desktop: DesktopRenewMiniOffice(data), + ScreenTypeLayout.builder( + mobile: (context) => MobileRenewMiniOffice(data!), + tablet: (context) => DesktopRenewMiniOffice(data!), + desktop: (context) => DesktopRenewMiniOffice(data!), ), ); } diff --git a/lib/pages/reset_password.dart b/lib/pages/reset_password.dart index 6ae09b7..2c5f10a 100644 --- a/lib/pages/reset_password.dart +++ b/lib/pages/reset_password.dart @@ -14,7 +14,7 @@ import '../widgets/mobile/mobile_reset_password.dart'; class ResetPassword extends StatelessWidget { final String mobile; final String code; - const ResetPassword(this.mobile, {Key key, this.code}) : super(key: key); + const ResetPassword(this.mobile, {Key? key, required this.code}) : super(key: key); @override Widget build(BuildContext context) { @@ -30,15 +30,15 @@ class ResetPassword extends StatelessWidget { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileResetPassword(mobile, code: code,), - tablet: DesktopResetPassword(mobile, code: code,), - desktop: DesktopResetPassword(mobile, code: code,), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileResetPassword(mobile, code: code,), + tablet: (context) => DesktopResetPassword(mobile, code: code,), + desktop: (context) => DesktopResetPassword(mobile, code: code,), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/search_place.dart b/lib/pages/search_place.dart index 158e68f..e852d64 100644 --- a/lib/pages/search_place.dart +++ b/lib/pages/search_place.dart @@ -5,18 +5,17 @@ import '../widgets/mobile/mobile_search_place.dart'; import 'package:responsive_builder/responsive_builder.dart'; class SearchPlace extends StatelessWidget { - final Key key; final int businessId; - const SearchPlace(this.businessId, {this.key}) : super(key: key); + const SearchPlace(this.businessId, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileSearchPlace(businessId), - tablet: DesktopSearchPlace(businessId), - desktop: DesktopSearchPlace(businessId), + ScreenTypeLayout.builder( + mobile: (context) => MobileSearchPlace(businessId), + tablet: (context) => DesktopSearchPlace(businessId), + desktop: (context) => DesktopSearchPlace(businessId), ), ); } diff --git a/lib/pages/set_password.dart b/lib/pages/set_password.dart index 1d30b5d..ac17a86 100644 --- a/lib/pages/set_password.dart +++ b/lib/pages/set_password.dart @@ -14,7 +14,7 @@ import '../widgets/mobile/mobile_set_password.dart'; class SetPassword extends StatelessWidget { final String mobile; final String code; - const SetPassword(this.mobile, {Key key, this.code}) : super(key: key); + const SetPassword(this.mobile, {Key? key, required this.code}) : super(key: key); @override Widget build(BuildContext context) { @@ -30,15 +30,15 @@ class SetPassword extends StatelessWidget { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileSetPassword(mobile, code: code,), - tablet: DesktopSetPassword(mobile, code: code,), - desktop: DesktopSetPassword(mobile, code: code,), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileSetPassword(mobile, code: code,), + tablet: (context) => DesktopSetPassword(mobile, code: code,), + desktop: (context) => DesktopSetPassword(mobile, code: code,), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/shop.dart b/lib/pages/shop.dart index fc8751b..1c958fa 100644 --- a/lib/pages/shop.dart +++ b/lib/pages/shop.dart @@ -8,9 +8,9 @@ import '../widgets/desktop/shop.dart' as desktop; import '../widgets/mobile/shop.dart' as mobile; class Shop extends StatefulWidget { - final int businessId; + final int? businessId; - const Shop({this.businessId, Key key}) : super(key: key); + const Shop({this.businessId, Key? key}) : super(key: key); @override State createState() => ShopState(); @@ -20,17 +20,17 @@ class ShopState extends State { @override Widget build(BuildContext context) { int _businessId = - widget.businessId == null ? Utils.getBusinessId() : widget.businessId; + widget.businessId == null ? Utils.getBusinessId() : widget.businessId!; return ResponsiveBuilder( - builder: (context, sizingInformation) => ScreenTypeLayout( - mobile: mobile.Shop( + builder: (context, sizingInformation) => ScreenTypeLayout.builder( + mobile: (context) => mobile.Shop( businessId: _businessId, ), - tablet: desktop.Shop( + tablet: (context) => desktop.Shop( businessId: _businessId, ), - desktop: desktop.Shop( + desktop: (context) => desktop.Shop( businessId: _businessId, ), ), diff --git a/lib/pages/store_product_search.dart b/lib/pages/store_product_search.dart index 434bcdb..9c8c892 100644 --- a/lib/pages/store_product_search.dart +++ b/lib/pages/store_product_search.dart @@ -15,7 +15,7 @@ import '../widgets/mobile/mobile_store_product_search.dart'; class StoreProductSearch extends StatelessWidget { final Business business; - const StoreProductSearch(this.business, {Key key}) : super(key: key); + const StoreProductSearch(this.business, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -31,15 +31,15 @@ class StoreProductSearch extends StatelessWidget { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileStoreProductSearch(business,), - tablet: DesktopStoreProductSearch(business), - desktop: DesktopStoreProductSearch(business), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileStoreProductSearch(business,), + tablet: (context) => DesktopStoreProductSearch(business), + desktop: (context) => DesktopStoreProductSearch(business), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 1,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 1,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/stripe_pay_web.dart b/lib/pages/stripe_pay_web.dart index 9d4c2d8..237b32a 100644 --- a/lib/pages/stripe_pay_web.dart +++ b/lib/pages/stripe_pay_web.dart @@ -13,7 +13,7 @@ import '../widgets/mobile/mobile_stripe_pay_web.dart'; class StripePayWeb extends StatelessWidget { final Order order; final PaymentPlatform paymentPlatform; - final StripePaymentMethod stripePaymentMethod; + final StripePaymentMethod? stripePaymentMethod; const StripePayWeb(this.order, this.paymentPlatform, {this.stripePaymentMethod}); @@ -23,10 +23,10 @@ class StripePayWeb extends StatelessWidget { return ResponsiveBuilder( builder: (context, sizingInformation) => - ScreenTypeLayout( - mobile: MobileStripePayWeb(order, paymentPlatform, stripePaymentMethod: stripePaymentMethod,), - tablet: DesktopStripePayWeb(order, paymentPlatform, stripePaymentMethod: stripePaymentMethod,), - desktop: DesktopStripePayWeb(order, paymentPlatform, stripePaymentMethod: stripePaymentMethod,), + ScreenTypeLayout.builder( + mobile: (context) => MobileStripePayWeb(order, paymentPlatform, stripePaymentMethod: stripePaymentMethod,), + tablet: (context) => DesktopStripePayWeb(order, paymentPlatform, stripePaymentMethod: stripePaymentMethod,), + desktop: (context) => DesktopStripePayWeb(order, paymentPlatform, stripePaymentMethod: stripePaymentMethod,), ), ); } diff --git a/lib/pages/user_profile.dart b/lib/pages/user_profile.dart index a642db7..1624178 100644 --- a/lib/pages/user_profile.dart +++ b/lib/pages/user_profile.dart @@ -13,7 +13,7 @@ import '../widgets/mobile/MobileBottomNav.dart'; import '../widgets/mobile/mobile_user_profile.dart'; class UserProfile extends StatelessWidget { - const UserProfile({Key key}) : super(key: key); + const UserProfile({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -29,15 +29,15 @@ class UserProfile extends StatelessWidget { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileUserProfile(), - tablet: DesktopUserProfile(), - desktop: DesktopUserProfile(), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileUserProfile(), + tablet: (context) => DesktopUserProfile(), + desktop: (context) => DesktopUserProfile(), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/view_blog.dart b/lib/pages/view_blog.dart index 1727713..aa4ea42 100644 --- a/lib/pages/view_blog.dart +++ b/lib/pages/view_blog.dart @@ -14,10 +14,9 @@ import '../widgets/mobile/MobileBottomNav.dart'; import '../widgets/mobile/mobile_view_blog.dart'; class ViewBlog extends StatefulWidget { - final Key key; final int bid; - const ViewBlog(this.bid, {this.key}) : super(key: key); + const ViewBlog(this.bid, {Key? key}) : super(key: key); @override State createState() { @@ -51,15 +50,15 @@ class ViewBlogState extends State { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileViewBlog(widget.bid), - tablet: DesktopViewBlog(widget.bid), - desktop: DesktopViewBlog(widget.bid), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileViewBlog(widget.bid), + tablet: (context) => DesktopViewBlog(widget.bid), + desktop: (context) => DesktopViewBlog(widget.bid), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/pages/view_ticket.dart b/lib/pages/view_ticket.dart index 9f5c935..3d5b192 100644 --- a/lib/pages/view_ticket.dart +++ b/lib/pages/view_ticket.dart @@ -14,10 +14,9 @@ import '../widgets/mobile/MobileBottomNav.dart'; import '../widgets/mobile/mobile_view_ticket.dart'; class ViewTicket extends StatefulWidget { - final Key key; final int ticketId; - const ViewTicket(this.ticketId, {this.key}) : super(key: key); + const ViewTicket(this.ticketId, {Key? key}) : super(key: key); @override State createState() { @@ -51,15 +50,15 @@ class ViewTicketState extends State { breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT, ), drawer: null, - body: ScreenTypeLayout( - mobile: MobileViewTicket(widget.ticketId), - tablet: DesktopViewTicket(widget.ticketId), - desktop: DesktopViewTicket(widget.ticketId), + body: ScreenTypeLayout.builder( + mobile: (context) => MobileViewTicket(widget.ticketId), + tablet: (context) => DesktopViewTicket(widget.ticketId), + desktop: (context) => DesktopViewTicket(widget.ticketId), ), - bottomNavigationBar: ScreenTypeLayout( - mobile: MobileBottomNav(currentIndex: 0,), - tablet: BottomNav(), - desktop: BottomNav(), + bottomNavigationBar: ScreenTypeLayout.builder( + mobile: (context) => MobileBottomNav(currentIndex: 0,), + tablet: (context) => BottomNav(), + desktop: (context) => BottomNav(), ), ), ); diff --git a/lib/routes.dart b/lib/routes.dart index 0efb875..0149558 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -44,169 +44,169 @@ class Routes { static void configure() { router.define('/', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return Home(title: Constants.APP_TITLE,); }), transitionType: TransitionType.fadeIn ); router.define('/download', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return Download(); }), transitionType: TransitionType.inFromRight ); router.define('/minipos-learn-more', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return MiniPosLearnMore(); }), transitionType: TransitionType.inFromRight ); router.define('/igoshow-learn-more', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return IGoShowLearnMore(); }), transitionType: TransitionType.inFromRight ); router.define('/login', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return Login(); }), transitionType: TransitionType.inFromRight ); router.define('/me', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return Me(); }), transitionType: TransitionType.inFromRight ); router.define('/change-password', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return ChangePassword(); }), transitionType: TransitionType.inFromRight ); router.define('/user-profile', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return UserProfile(); }), transitionType: TransitionType.inFromRight ); router.define('/new-user', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return NewUser(); }), transitionType: TransitionType.inFromRight ); router.define('/set-password/:mobile/:code', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return SetPassword(params['mobile'][0], code: params['code'][0]); + handlerFunc: (BuildContext? context, Map> params) { + return SetPassword(params['mobile']![0], code: params['code']![0]); } )); router.define('/forgot-password', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return ForgotPassword(); } )); router.define('/reset-password/:mobile/:code', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return ResetPassword(params['mobile'][0], code: params['code'][0]); + handlerFunc: (BuildContext? context, Map> params) { + return ResetPassword(params['mobile']![0], code: params['code']![0]); } )); router.define('/change-mobile-email/:ismobile', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - if (params['ismobile'][0] == '1') { + handlerFunc: (BuildContext? context, Map> params) { + if (params['ismobile']![0] == '1') { return ChangeMobileOrEmail(true); } return ChangeMobileOrEmail(false); } )); router.define('/my-addresses/:business_id', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return MyAddresses(businessId: int.parse(params['business_id'][0]),); + handlerFunc: (BuildContext? context, Map> params) { + return MyAddresses(businessId: int.parse(params['business_id']![0]),); } )); router.define('/my-support/:business_id', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return MySupport(businessId: int.parse(params['business_id'][0]),); + handlerFunc: (BuildContext? context, Map> params) { + return MySupport(businessId: int.parse(params['business_id']![0]),); } )); router.define('/new-ticket/:business_id', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return NewTicket(businessId: int.parse(params['business_id'][0]),); + handlerFunc: (BuildContext? context, Map> params) { + return NewTicket(businessId: int.parse(params['business_id']![0]),); } )); router.define('/search-place/:business_id', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return SearchPlace(int.parse(params['business_id'][0])); + handlerFunc: (BuildContext? context, Map> params) { + return SearchPlace(int.parse(params['business_id']![0])); } )); router.define('/view-ticket/:ticket_id', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return ViewTicket(int.parse(params['ticket_id'][0]),); + handlerFunc: (BuildContext? context, Map> params) { + return ViewTicket(int.parse(params['ticket_id']![0]),); } )); router.define('/blog/:business_id', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return Blog(businessId: int.parse(params['business_id'][0]),); + handlerFunc: (BuildContext? context, Map> params) { + return Blog(businessId: int.parse(params['business_id']![0]),); } )); router.define('/view-blog/:bid', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return ViewBlog(int.parse(params['bid'][0]),); + handlerFunc: (BuildContext? context, Map> params) { + return ViewBlog(int.parse(params['bid']![0]),); } )); router.define('/shop/:business_id', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return Shop(businessId: int.parse(params['business_id'][0]),); + handlerFunc: (BuildContext? context, Map> params) { + return Shop(businessId: int.parse(params['business_id']![0]),); } )); router.define('/shop', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return Shop(); } )); // router.define('/ocr-scan', handler: new Handler( - // handlerFunc: (BuildContext context, Map> params) { + // handlerFunc: (BuildContext? context, Map> params) { // return OCRScan(); // } // )); router.define('/checkout/:id', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return Checkout(int.parse(params['id'][0])); + handlerFunc: (BuildContext? context, Map> params) { + return Checkout(int.parse(params['id']![0])); }), ); router.define('/paynow/:orderId', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return PayNow(int.parse(params['orderId'][0])); + handlerFunc: (BuildContext? context, Map> params) { + return PayNow(int.parse(params['orderId']![0])); }), ); router.define('/orders', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return Orders(); } )); router.define('/my-cards', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return MyCards(); } )); router.define('/orderdetail/:orderId', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return OrderDetail(int.parse(params['orderId'][0])); + handlerFunc: (BuildContext? context, Map> params) { + return OrderDetail(int.parse(params['orderId']![0])); }), ); router.define('/new-comment/:orderId', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return NewComment(int.parse(params['orderId'][0])); + handlerFunc: (BuildContext? context, Map> params) { + return NewComment(int.parse(params['orderId']![0])); }), ); router.define('/coupons/:contactId', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return Coupons(int.parse(params['contactId'][0])); + handlerFunc: (BuildContext? context, Map> params) { + return Coupons(int.parse(params['contactId']![0])); }), ); router.define('/service-policy', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return PlainPage( 'service-policy', // businessId: Constants.BUSINESS_ID, @@ -215,7 +215,7 @@ class Routes { }), ); router.define('/return-policy', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return PlainPage( 'return-policy', // businessId: Constants.BUSINESS_ID, @@ -224,7 +224,7 @@ class Routes { }), ); router.define('/privacy-policy', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return PlainPage( 'privacy-policy', // businessId: Constants.BUSINESS_ID, @@ -233,7 +233,7 @@ class Routes { }), ); router.define('/end-user-license-agreement', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return PlainPage( 'end-user-license-agreement', // businessId: Constants.BUSINESS_ID, @@ -242,7 +242,7 @@ class Routes { }), ); router.define('/about-us', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return PlainPage( 'about-us', // businessId: Constants.BUSINESS_ID, @@ -251,29 +251,29 @@ class Routes { }), ); router.define('/contact-us', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return ContactUs( businessId: Constants.BUSINESS_ID, ); }), ); router.define('/renew-license', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return RenewLicense(); } )); router.define('/renew-minioffice/:gid', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return RenewMiniOffice(int.parse(params['gid'][0])); + handlerFunc: (BuildContext? context, Map> params) { + return RenewMiniOffice(int.parse(params['gid']![0])); } )); router.define('/buy-service/:gid/:servicename', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { - return BuyService(int.parse(params['gid'][0]), params['servicename'][0]); + handlerFunc: (BuildContext? context, Map> params) { + return BuyService(int.parse(params['gid']![0]), params['servicename']![0]); } )); router.define('/contact-stores', handler: new Handler( - handlerFunc: (BuildContext context, Map> params) { + handlerFunc: (BuildContext? context, Map> params) { return CreateOnlineStore1(); } )); diff --git a/lib/store/actions.dart b/lib/store/actions.dart index 2b96ca6..ee142a0 100644 --- a/lib/store/actions.dart +++ b/lib/store/actions.dart @@ -10,17 +10,17 @@ class UpdateContext { } class UpdateLocale { - final Locale locale; + final Locale? locale; UpdateLocale(this.locale); } class UpdateCurrentUser { - final User user; + final User? user; UpdateCurrentUser(this.user); } class UpdateRedirectRoute { - final String route; + final String? route; UpdateRedirectRoute(this.route); } diff --git a/lib/store/reducer/cart_info_reducer.dart b/lib/store/reducer/cart_info_reducer.dart index 4f2db10..db354f8 100644 --- a/lib/store/reducer/cart_info_reducer.dart +++ b/lib/store/reducer/cart_info_reducer.dart @@ -4,10 +4,10 @@ import 'package:redux/redux.dart'; import '../actions.dart'; -final cartInfoReducer = combineReducers>([ - TypedReducer, UpdateCartInfo>(_updateCartInfo) +final cartInfoReducer = combineReducers?>([ + TypedReducer?, UpdateCartInfo>(_updateCartInfo) ]); -List _updateCartInfo(List cartInfos, action) { +List _updateCartInfo(List? cartInfos, action) { return action.cartInfos; } \ No newline at end of file diff --git a/lib/store/reducer/context_reducer.dart b/lib/store/reducer/context_reducer.dart index 586d72c..022bfda 100644 --- a/lib/store/reducer/context_reducer.dart +++ b/lib/store/reducer/context_reducer.dart @@ -3,10 +3,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_wisetronic/store/actions.dart'; import 'package:redux/redux.dart'; -final contextReducer = combineReducers([ - TypedReducer(_updateContext) +final contextReducer = combineReducers([ + TypedReducer(_updateContext) ]); -BuildContext _updateContext(BuildContext context, action) { +BuildContext _updateContext(BuildContext? context, action) { return action.context; } \ No newline at end of file diff --git a/lib/store/reducer/device_id_reducer.dart b/lib/store/reducer/device_id_reducer.dart index b7942ab..6c6fe5a 100644 --- a/lib/store/reducer/device_id_reducer.dart +++ b/lib/store/reducer/device_id_reducer.dart @@ -2,10 +2,10 @@ import 'package:redux/redux.dart'; import '../actions.dart'; -final deviceIdReducer = combineReducers([ - TypedReducer(_updateDeviceId) +final deviceIdReducer = combineReducers([ + TypedReducer(_updateDeviceId) ]); -String _updateDeviceId(String deviceId, action) { +String _updateDeviceId(String? deviceId, action) { return action.deviceId; } \ No newline at end of file diff --git a/lib/store/reducer/fcmtoken_reducer.dart b/lib/store/reducer/fcmtoken_reducer.dart index 6a4c228..5f8254e 100644 --- a/lib/store/reducer/fcmtoken_reducer.dart +++ b/lib/store/reducer/fcmtoken_reducer.dart @@ -2,10 +2,10 @@ import 'package:redux/redux.dart'; import '../actions.dart'; -final fcmtokenReducer = combineReducers([ - TypedReducer(_updateFcmToken) +final fcmtokenReducer = combineReducers([ + TypedReducer(_updateFcmToken) ]); -String _updateFcmToken(String token, action) { +String _updateFcmToken(String? token, action) { return action.token; } \ No newline at end of file diff --git a/lib/store/reducer/last_visit_reducer.dart b/lib/store/reducer/last_visit_reducer.dart index 5531bfa..d7e4d9a 100644 --- a/lib/store/reducer/last_visit_reducer.dart +++ b/lib/store/reducer/last_visit_reducer.dart @@ -2,10 +2,10 @@ import 'package:redux/redux.dart'; import '../actions.dart'; -final lastVisitReducer = combineReducers>([ - TypedReducer, UpdateLastVisit>(_updateLastVisit) +final lastVisitReducer = combineReducers?>([ + TypedReducer?, UpdateLastVisit>(_updateLastVisit) ]); -List _updateLastVisit(List lastVisit, action) { +List _updateLastVisit(List? lastVisit, action) { return action.lastVisit; } \ No newline at end of file diff --git a/lib/store/reducer/locale_reducer.dart b/lib/store/reducer/locale_reducer.dart index d27f351..f09fc21 100644 --- a/lib/store/reducer/locale_reducer.dart +++ b/lib/store/reducer/locale_reducer.dart @@ -2,10 +2,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_wisetronic/store/actions.dart'; import 'package:redux/redux.dart'; -final localeReducer = combineReducers([ - TypedReducer(_updateLocale) +final localeReducer = combineReducers([ + TypedReducer(_updateLocale) ]); -Locale _updateLocale(Locale locale, action) { +Locale _updateLocale(Locale? locale, action) { return action.locale; } \ No newline at end of file diff --git a/lib/store/reducer/locate_address_reducer.dart b/lib/store/reducer/locate_address_reducer.dart index 1004a56..b667527 100644 --- a/lib/store/reducer/locate_address_reducer.dart +++ b/lib/store/reducer/locate_address_reducer.dart @@ -3,10 +3,10 @@ import 'package:redux/redux.dart'; import '../../models/located_address.dart'; import '../actions.dart'; -final locatedAddressReducer = combineReducers([ - TypedReducer(_updateLocatedAddress) +final locatedAddressReducer = combineReducers([ + TypedReducer(_updateLocatedAddress) ]); -LocatedAddress _updateLocatedAddress(LocatedAddress locatedAddress, action) { +LocatedAddress _updateLocatedAddress(LocatedAddress? locatedAddress, action) { return action.locatedAddress; } \ No newline at end of file diff --git a/lib/store/reducer/redirect_route_reducer.dart b/lib/store/reducer/redirect_route_reducer.dart index 14c57ec..31b1182 100644 --- a/lib/store/reducer/redirect_route_reducer.dart +++ b/lib/store/reducer/redirect_route_reducer.dart @@ -2,10 +2,10 @@ import 'package:redux/redux.dart'; import '../actions.dart'; -final redirectRouteReducer = combineReducers([ - TypedReducer(_updateRedirectRoute) +final redirectRouteReducer = combineReducers([ + TypedReducer(_updateRedirectRoute) ]); -String _updateRedirectRoute(String route, action) { +String? _updateRedirectRoute(String? route, action) { return action.route; } \ No newline at end of file diff --git a/lib/store/reducer/table_number_reducer.dart b/lib/store/reducer/table_number_reducer.dart index 6653ad8..81c60b6 100644 --- a/lib/store/reducer/table_number_reducer.dart +++ b/lib/store/reducer/table_number_reducer.dart @@ -2,10 +2,10 @@ import 'package:redux/redux.dart'; import '../actions.dart'; -final tableNumberReducer = combineReducers([ - TypedReducer(_updateTableNumber) +final tableNumberReducer = combineReducers([ + TypedReducer(_updateTableNumber) ]); -String _updateTableNumber(String tableNumber, action) { +String _updateTableNumber(String? tableNumber, action) { return action.tableNumber; } \ No newline at end of file diff --git a/lib/store/reducer/user_reducer.dart b/lib/store/reducer/user_reducer.dart index d15912d..698d816 100644 --- a/lib/store/reducer/user_reducer.dart +++ b/lib/store/reducer/user_reducer.dart @@ -4,10 +4,10 @@ import 'package:flutter_wisetronic/models/user.dart'; import '../actions.dart'; -final userReducer = combineReducers([ - TypedReducer(_updateCurrentUser) +final userReducer = combineReducers([ + TypedReducer(_updateCurrentUser) ]); -User _updateCurrentUser(User user, action) { +User? _updateCurrentUser(User? user, action) { return action.user; } \ No newline at end of file diff --git a/lib/store/state/app_state.dart b/lib/store/state/app_state.dart index 44e9d57..a7c4886 100644 --- a/lib/store/state/app_state.dart +++ b/lib/store/state/app_state.dart @@ -6,16 +6,16 @@ import '../../models/user.dart'; @immutable class AppState { - final BuildContext context; - final Locale locale; - final User user; - final String redirectRoute; - final List cartInfos; - final LocatedAddress locatedAddress; - final String fcmToken; - final List lastVisit; - final String deviceId; - final String tableNumber; + final BuildContext? context; + final Locale? locale; + final User? user; + final String? redirectRoute; + final List? cartInfos; + final LocatedAddress? locatedAddress; + final String? fcmToken; + final List? lastVisit; + final String? deviceId; + final String? tableNumber; AppState({this.context, this.locale, this.user, this.redirectRoute, this.cartInfos, this.locatedAddress, this.fcmToken, this.lastVisit, @@ -24,8 +24,8 @@ class AppState { factory AppState.init() => AppState(); AppState copyWith({ - BuildContext context, - Locale locale}) { + BuildContext? context, + Locale? locale}) { return AppState( context: context ?? this.context, locale: locale ?? this.locale, diff --git a/lib/utils/double_back_to_close_app.dart b/lib/utils/double_back_to_close_app.dart index b39eee3..9d2923b 100644 --- a/lib/utils/double_back_to_close_app.dart +++ b/lib/utils/double_back_to_close_app.dart @@ -21,9 +21,9 @@ class DoubleBackToCloseApp extends StatefulWidget { /// Creates a widget that allows the user to close the app by double tapping /// the back-button. const DoubleBackToCloseApp({ - Key key, - @required this.snackBar, - @required this.child, + Key? key, + required this.snackBar, + required this.child, }) : assert(snackBar != null), assert(child != null), super(key: key); @@ -34,7 +34,7 @@ class DoubleBackToCloseApp extends StatefulWidget { class _DoubleBackToCloseAppState extends State { /// The last time the user tapped Android's back-button. - DateTime _lastTimeBackButtonWasTapped; + DateTime? _lastTimeBackButtonWasTapped; /// Returns whether the current platform is Android. bool get _isAndroid => Theme.of(context).platform == TargetPlatform.android; @@ -50,7 +50,7 @@ class _DoubleBackToCloseAppState extends State { bool get _isSnackBarVisible => (_lastTimeBackButtonWasTapped != null) && (widget.snackBar.duration > - DateTime.now().difference(_lastTimeBackButtonWasTapped)); + DateTime.now().difference(_lastTimeBackButtonWasTapped!)); /// Returns whether the next back navigation of this route will be handled /// internally. @@ -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/fake_iframe_web.dart b/lib/utils/fake_iframe_web.dart index a3a26b3..a8edf9a 100644 --- a/lib/utils/fake_iframe_web.dart +++ b/lib/utils/fake_iframe_web.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; class IFrameWeb extends StatefulWidget { - final String width; - final String height; - final String src; + final String? width; + final String? height; + final String? src; const IFrameWeb({this.width, this.height, this.src}); diff --git a/lib/utils/http_util.dart b/lib/utils/http_util.dart index bbd669c..188a657 100644 --- a/lib/utils/http_util.dart +++ b/lib/utils/http_util.dart @@ -7,14 +7,12 @@ import 'package:crypto/crypto.dart'; import 'package:dio/dio.dart'; import '../store/store.dart'; import 'utils.dart'; -import 'package:hive/hive.dart'; -import 'package:universal_io/io.dart'; import '../constants.dart'; typedef void PostCallback(Response response); -String generateSignature(String string, {String key}) { +String generateSignature(String string, {String? key}) { if (key == null) { key = Constants.API_SECRET; } @@ -37,17 +35,17 @@ 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 == null || store.state == null || store.state.locale == null) ? 'en' : store.state.locale!.languageCode, + 'Http-Country-Code': (store == null || store.state == null || store.state.locale == null) ? 'US' : store.state.locale!.countryCode!, }; static Future httpGet(String url, { - Map queryParameters, + Map? queryParameters, int businessId = 0, - Function(int, int) receiveProgress, + Function(int, int)? receiveProgress, bool returnError = false, - Map additionalHeaders, + Map? additionalHeaders, }) async { Map localHeaders = json.decode(json.encode(headers)); if (additionalHeaders != null) { @@ -59,8 +57,7 @@ class HttpUtil { } localHeaders['Http-Business-Id'] = businessId == 0 ? '${Constants.BUSINESS_ID}' : businessId.toString(); - Box box = await Utils.getBox(); - localHeaders['Http-Contact-Authorization'] = box.get(Constants.KEY_ACCESS_TOKEN, defaultValue: ''); + localHeaders['Http-Contact-Authorization'] = Utils.prefs?.getString(Constants.KEY_ACCESS_TOKEN) ?? ''; localHeaders['Http-App-Key'] = platformName; localHeaders['Http-Device-Type'] = platformName; String requestUrl = Constants.BASE_API_URL + url; @@ -69,7 +66,9 @@ class HttpUtil { requestUrl = url; } - Utils.jsonPrettyPrint(queryParameters); + if (queryParameters != null) { + Utils.jsonPrettyPrint(queryParameters!); + } Dio dio = Dio(); try { @@ -84,9 +83,9 @@ class HttpUtil { // print('response data: ${response.data}'); // Utils.jsonPrettyPrint(response.data); - int statusCode = response.statusCode; + int statusCode = response.statusCode!; return response.data; - } on DioError catch(e) { + } on DioException catch(e) { print('HttpGet failed, request: $requestUrl, headers: $localHeaders, error ${e.response}'); if (returnError) { return e; @@ -95,16 +94,16 @@ class HttpUtil { } } - static Future httpPost(String url, PostCallback callback, + static Future httpPost(String url, PostCallback? callback, { - Map queryParameters, + Map? queryParameters, int businessId = 0, bool isFormData = false, - Map additionalHeaders, - Map body, - FormData formData, - Function(int, int) sendProgress, - Function(int, int) receiveProgress, + Map? additionalHeaders, + Map? body, + FormData? formData, + Function(int, int)? sendProgress, + Function(int, int)? receiveProgress, bool returnError = false, }) async { @@ -116,8 +115,7 @@ class HttpUtil { localHeaders['Http-Signature'] = generateSignature(url); } localHeaders['Http-Business-Id'] = businessId == 0 ? '${Constants.BUSINESS_ID}' : businessId.toString(); - Box box = await Utils.getBox(); - localHeaders['Http-Contact-Authorization'] = box.get(Constants.KEY_ACCESS_TOKEN, defaultValue: ''); + localHeaders['Http-Contact-Authorization'] = Utils.prefs?.getString(Constants.KEY_ACCESS_TOKEN) ?? ''; localHeaders['Http-App-Key'] = platformName; localHeaders['Http-Device-Type'] = platformName; @@ -138,7 +136,7 @@ class HttpUtil { Response response = await dio.post( requestUrl, queryParameters: queryParameters == null ? {} : queryParameters, - data: isFormData ? ((formData != null)?formData:FormData.fromMap(body)) : json.encode(body), + data: isFormData ? ((formData != null)?formData:FormData.fromMap(body!)) : json.encode(body), options: Options( headers: localHeaders, contentType: isFormData ? Headers.formUrlEncodedContentType : Headers.jsonContentType, @@ -149,17 +147,17 @@ class HttpUtil { // Utils.jsonPrettyPrint(response.data); - int statusCode = response.statusCode; + int statusCode = response.statusCode!; if (callback != null) { callback(response); } return response.data; - } on DioError catch(e, stacktrace) { + } on DioException catch(e, stacktrace) { if (e.response != null) { try { - Utils.jsonPrettyPrint(e.response.data); + Utils.jsonPrettyPrint(e.response?.data); } catch (err) { - print(e.response.data); + print(e.response?.data); } } if (returnError) { @@ -169,14 +167,14 @@ class HttpUtil { } } - static Future httpPut(String url, PostCallback callback, + static Future httpPut(String url, PostCallback? callback, { - Map queryParameters, + Map? queryParameters, int businessId = 0, - Map additionalHeaders, - Map body, - Function(int, int) sendProgress, - Function(int, int) receiveProgress, + Map? additionalHeaders, + Map? body, + Function(int, int)? sendProgress, + Function(int, int)? receiveProgress, bool returnError = false, }) async { @@ -190,8 +188,7 @@ class HttpUtil { } localHeaders['Http-Business-Id'] = businessId == 0 ? '${Constants.BUSINESS_ID}' : businessId.toString(); - Box box = await Utils.getBox(); - localHeaders['Http-Contact-Authorization'] = box.get(Constants.KEY_ACCESS_TOKEN, defaultValue: ''); + localHeaders['Http-Contact-Authorization'] = Utils.prefs?.getString(Constants.KEY_ACCESS_TOKEN) ?? ''; localHeaders['Http-App-Key'] = platformName; localHeaders['Http-Device-Type'] = platformName; @@ -218,14 +215,14 @@ class HttpUtil { // Utils.jsonPrettyPrint(response.data); - int statusCode = response.statusCode; + int statusCode = response.statusCode!; if (callback != null) { callback(response); } return response.data; - } on DioError catch(e) { + } on DioException catch(e) { if (e.response != null) { - Utils.jsonPrettyPrint(e.response.data); + Utils.jsonPrettyPrint(e.response!.data); } if (returnError) { return e; @@ -234,14 +231,14 @@ class HttpUtil { } } - static Future httpPatch(String url, PostCallback callback, + static Future httpPatch(String url, PostCallback? callback, { - Map queryParameters, + Map? queryParameters, int businessId = 0, - Map additionalHeaders, - Map body, - Function(int, int) sendProgress, - Function(int, int) receiveProgress, + Map? additionalHeaders, + Map? body, + Function(int, int)? sendProgress, + Function(int, int)? receiveProgress, bool returnError = false, }) async { @@ -255,8 +252,7 @@ class HttpUtil { } localHeaders['Http-Business-Id'] = businessId == 0 ? '${Constants.BUSINESS_ID}' : businessId.toString(); - Box box = await Utils.getBox(); - localHeaders['Http-Contact-Authorization'] = box.get(Constants.KEY_ACCESS_TOKEN, defaultValue: ''); + localHeaders['Http-Contact-Authorization'] = Utils.prefs?.getString(Constants.KEY_ACCESS_TOKEN) ?? ''; localHeaders['Http-App-Key'] = platformName; localHeaders['Http-Device-Type'] = platformName; @@ -268,7 +264,9 @@ class HttpUtil { requestUrl = url; } - Utils.jsonPrettyPrint(body); + if (body != null) { + Utils.jsonPrettyPrint(body!); + } Dio dio = Dio(); try { @@ -285,14 +283,14 @@ class HttpUtil { // Utils.jsonPrettyPrint(response.data); - int statusCode = response.statusCode; + int statusCode = response.statusCode!; if (callback != null) { callback(response); } return response.data; - } on DioError catch(e) { + } on DioException catch(e) { if (e.response != null) { - Utils.jsonPrettyPrint(e.response.data); + Utils.jsonPrettyPrint(e.response!.data); } if (returnError) { return e; @@ -301,12 +299,12 @@ class HttpUtil { } } - static Future httpDelete(String url, PostCallback callback, + static Future httpDelete(String url, PostCallback? callback, { - Map queryParameters, + Map? queryParameters, int businessId = 0, - Map additionalHeaders, - Map body, + Map? additionalHeaders, + Map? body, bool returnError = false, }) async { @@ -320,8 +318,7 @@ class HttpUtil { } localHeaders['Http-Business-Id'] = businessId == 0 ? '${Constants.BUSINESS_ID}' : businessId.toString(); - Box box = await Utils.getBox(); - localHeaders['Http-Contact-Authorization'] = box.get(Constants.KEY_ACCESS_TOKEN, defaultValue: ''); + localHeaders['Http-Contact-Authorization'] = Utils.prefs?.getString(Constants.KEY_ACCESS_TOKEN) ?? ''; localHeaders['Http-App-Key'] = platformName; localHeaders['Http-Device-Type'] = platformName; @@ -333,7 +330,9 @@ class HttpUtil { requestUrl = url; } - Utils.jsonPrettyPrint(body); + if (body != null) { + Utils.jsonPrettyPrint(body); + } Dio dio = Dio(); try { @@ -348,14 +347,14 @@ class HttpUtil { // Utils.jsonPrettyPrint(response.data); - int statusCode = response.statusCode; + int statusCode = response.statusCode!; if (callback != null) { callback(response); } return response.data; - } on DioError catch(e) { + } on DioException catch(e) { if (e.response != null) { - Utils.jsonPrettyPrint(e.response.data); + Utils.jsonPrettyPrint(e.response!.data); } if(returnError) { return e; diff --git a/lib/utils/shop_scroll_controller.dart b/lib/utils/shop_scroll_controller.dart index f987c38..2402953 100644 --- a/lib/utils/shop_scroll_controller.dart +++ b/lib/utils/shop_scroll_controller.dart @@ -14,7 +14,7 @@ class ShopScrollController extends ScrollController { this.coordinator, { double initialScrollOffset = 0.0, this.keepScrollOffset = true, - this.debugLabel, + required this.debugLabel, }) : assert(initialScrollOffset != null), assert(keepScrollOffset != null), _initialScrollOffset = initialScrollOffset; @@ -61,7 +61,7 @@ class ShopScrollController extends ScrollController { 'ScrollController not attached to any scroll views.'); assert(_positions.length == 1, 'ScrollController attached to multiple scroll views.'); - return _positions.single; + return _positions.single as ShopScrollPosition; } /// 可滚动小部件的当前滚动偏移量 @@ -83,12 +83,12 @@ class ShopScrollController extends ScrollController { /// 持续时间不能为零。 要在没有动画的情况下跳至特定值,请使用[jumpTo]。 Future animateTo( double offset, { - @required Duration duration, - @required Curve curve, + required Duration duration, + required Curve curve, }) { assert(_positions.isNotEmpty, 'ScrollController not attached to any scroll views.'); - final List> animations = List>(_positions.length); + final List> animations = List>.filled(_positions.length, Future.value()); for (int i = 0; i < _positions.length; i += 1) animations[i] = _positions[i].animateTo(offset, duration: duration, curve: curve); @@ -149,7 +149,7 @@ class ShopScrollController extends ScrollController { /// 则它将是前一个实例。 当环境已更改并且[Scrollable]需要重新创建[ScrollPosition] /// 对象时,将使用此方法。 第一次创建[ScrollPosition]时为null。 ScrollPosition createScrollPosition(ScrollPhysics physics, - ScrollContext context, ScrollPosition oldPosition) { + ScrollContext context, ScrollPosition? oldPosition) { return ShopScrollPosition( coordinator: coordinator, physics: physics, diff --git a/lib/utils/shop_scroll_coordinator.dart b/lib/utils/shop_scroll_coordinator.dart index 624dbeb..27f9c39 100644 --- a/lib/utils/shop_scroll_coordinator.dart +++ b/lib/utils/shop_scroll_coordinator.dart @@ -12,15 +12,15 @@ class ShopScrollCoordinator { /// 页面主 CustomScrollView 控制 final String pageLabel = "page"; - ShopScrollController _pageScrollController; - double Function() pinnedHeaderSliverHeightBuilder; + ShopScrollController? _pageScrollController; + double Function()? pinnedHeaderSliverHeightBuilder; - ShopScrollPosition get _pageScrollPosition => _pageScrollController.position; + ShopScrollPosition get _pageScrollPosition => _pageScrollController!.position; - ScrollDragController scrollDragController; + ScrollDragController? scrollDragController; /// 主页面滑动部件默认位置 - double _pageInitialOffset; + double? _pageInitialOffset; /// 获取主页面滑动控制器 ShopScrollController pageScrollController([double initialOffset = 0.0]) { @@ -28,27 +28,27 @@ class ShopScrollCoordinator { _pageInitialOffset = initialOffset; _pageScrollController = ShopScrollController(this, debugLabel: pageLabel, initialScrollOffset: initialOffset); - return _pageScrollController; + return _pageScrollController!; } /// 创建并获取一个子滑动控制器 - ShopScrollController newChildScrollController([String debugLabel]) => - ShopScrollController(this, debugLabel: debugLabel); + ShopScrollController newChildScrollController([String? debugLabel]) => + ShopScrollController(this, debugLabel: debugLabel ?? ''); /// 子部件滑动数据协调 /// [userScrollDirection]用户滑动方向 /// [position]被滑动的子部件的位置信息 void applyUserOffset(double delta, - [ScrollDirection userScrollDirection, ShopScrollPosition position]) { + [ScrollDirection? userScrollDirection, ShopScrollPosition? position]) { if (userScrollDirection == ScrollDirection.reverse) { - updateUserScrollDirection(_pageScrollPosition, userScrollDirection); + updateUserScrollDirection(_pageScrollPosition, userScrollDirection!); final innerDelta = _pageScrollPosition.applyClampedDragUpdate(delta); if (innerDelta != 0.0) { - updateUserScrollDirection(position, userScrollDirection); + updateUserScrollDirection(position!, userScrollDirection); position.applyFullDragUpdate(innerDelta); } } else { - updateUserScrollDirection(position, userScrollDirection); + updateUserScrollDirection(position!, userScrollDirection!); final outerDelta = position.applyClampedDragUpdate(delta); if (outerDelta != 0.0) { updateUserScrollDirection(_pageScrollPosition, userScrollDirection); @@ -60,7 +60,7 @@ class ShopScrollCoordinator { bool applyContentDimensions(double minScrollExtent, double maxScrollExtent, ShopScrollPosition position) { if (pinnedHeaderSliverHeightBuilder != null) { - maxScrollExtent = maxScrollExtent - pinnedHeaderSliverHeightBuilder(); + maxScrollExtent = maxScrollExtent - pinnedHeaderSliverHeightBuilder!(); maxScrollExtent = math.max(0.0, maxScrollExtent); } return position.applyContentDimensions( @@ -77,9 +77,9 @@ class ShopScrollCoordinator { /// 当手指离开屏幕 void onPointerUp(PointerUpEvent event) { final double _pagePixels = _pageScrollPosition.pixels; - if (0.0 < _pagePixels && _pagePixels < _pageInitialOffset) { + if (0.0 < _pagePixels && _pagePixels < _pageInitialOffset!) { if (pageExpand == PageExpandState.NotExpand && - _pageInitialOffset - _pagePixels > _scrollRedundancy) { + _pageInitialOffset! - _pagePixels > _scrollRedundancy) { _pageScrollPosition .animateTo(0.0, duration: const Duration(milliseconds: 400), curve: Curves.ease) @@ -87,7 +87,7 @@ class ShopScrollCoordinator { } else { pageExpand = PageExpandState.Expanding; _pageScrollPosition - .animateTo(_pageInitialOffset, + .animateTo(_pageInitialOffset!, duration: const Duration(milliseconds: 400), curve: Curves.ease) .then((value) => pageExpand = PageExpandState.NotExpand); } diff --git a/lib/utils/shop_scroll_position.dart b/lib/utils/shop_scroll_position.dart index 448e314..abbed27 100644 --- a/lib/utils/shop_scroll_position.dart +++ b/lib/utils/shop_scroll_position.dart @@ -11,17 +11,17 @@ import 'shop_scroll_coordinator.dart'; class ShopScrollPosition extends ScrollPosition implements ScrollActivityDelegate { final ShopScrollCoordinator coordinator; // 协调器 - ScrollDragController _currentDrag; + ScrollDragController? _currentDrag; double _heldPreviousVelocity = 0.0; ShopScrollPosition( - {@required ScrollPhysics physics, - @required ScrollContext context, + {required ScrollPhysics physics, + required ScrollContext context, double initialPixels = 0.0, bool keepScrollOffset = true, - ScrollPosition oldPosition, - String debugLabel, - @required this.coordinator}) + ScrollPosition? oldPosition, + String? debugLabel, + required this.coordinator}) : super( physics: physics, context: context, @@ -40,7 +40,7 @@ class ShopScrollPosition extends ScrollPosition @override double setPixels(double newPixels) { - assert(activity.isScrolling); + assert(activity!.isScrolling); return super.setPixels(newPixels); } @@ -51,13 +51,13 @@ class ShopScrollPosition extends ScrollPosition goIdle(); return; } - activity.updateDelegate(this); + activity!.updateDelegate(this); final ShopScrollPosition typedOther = other as ShopScrollPosition; _userScrollDirection = typedOther._userScrollDirection; assert(_currentDrag == null); if (typedOther._currentDrag != null) { _currentDrag = typedOther._currentDrag; - _currentDrag.updateDelegate(this); + _currentDrag?.updateDelegate(this); typedOther._currentDrag = null; } } @@ -131,14 +131,14 @@ class ShopScrollPosition extends ScrollPosition } @override - void beginActivity(ScrollActivity newActivity) { + void beginActivity(ScrollActivity? newActivity) { _heldPreviousVelocity = 0.0; if (newActivity == null) return; assert(newActivity.delegate == this); super.beginActivity(newActivity); _currentDrag?.dispose(); _currentDrag = null; - if (!activity.isScrolling) updateUserScrollDirection(ScrollDirection.idle); + if (!activity!.isScrolling) updateUserScrollDirection(ScrollDirection.idle); } /// 将[用户滚动方向]设置为给定值。 @@ -154,7 +154,7 @@ class ShopScrollPosition extends ScrollPosition @override ScrollHoldController hold(VoidCallback holdCancelCallback) { - final double previousVelocity = activity.velocity; + final double previousVelocity = activity!.velocity; final HoldScrollActivity holdActivity = HoldScrollActivity(delegate: this, onHoldCanceled: holdCancelCallback); beginActivity(holdActivity); @@ -195,10 +195,10 @@ class ShopScrollPosition extends ScrollPosition if (coordinator.pageExpand == PageExpandState.Expanding) return; } assert(pixels != null); - final Simulation simulation = + final Simulation? simulation = physics.createBallisticSimulation(this, velocity); if (simulation != null) { - beginActivity(BallisticScrollActivity(this, simulation, context.vsync)); + beginActivity(BallisticScrollActivity(this, simulation, context.vsync, true)); } else { goIdle(); } @@ -220,8 +220,8 @@ class ShopScrollPosition extends ScrollPosition @override Future animateTo( double to, { - @required Duration duration, - @required Curve curve, + required Duration duration, + required Curve curve, }) { if (nearEqual(to, pixels, physics.tolerance.distance)) { // 跳过动画,直接移到我们已经靠近的位置。 diff --git a/lib/utils/util_io.dart b/lib/utils/util_io.dart index 18847c3..2e58d67 100644 --- a/lib/utils/util_io.dart +++ b/lib/utils/util_io.dart @@ -6,15 +6,11 @@ import 'dart:ui' as ui; import 'package:cached_network_image/cached_network_image.dart'; import 'package:dio/dio.dart'; -// import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_local_notifications/flutter_local_notifications.dart'; -import 'package:hive/hive.dart'; import 'package:image_picker/image_picker.dart'; import 'package:path/path.dart'; -import 'package:path_provider/path_provider.dart'; import 'package:stripe_payment/stripe_payment.dart'; import '../constants.dart'; @@ -42,174 +38,17 @@ class Util { } Util._internal(); - // final FirebaseMessaging firebaseMessaging = FirebaseMessaging(); - final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin(); static bool notificationTapped = false; - init() { - // initLocalNotification(); - // initFirebaseMessaging(); - - // ePmqRwRUTmKuFNfbHA-6zq:APA91bEFEQx1YgJqfx0V0VYo86uRDGjG6SP1SPCAZW4OvQ7gMOeKWDQ47bfuEM00YavtKq7ZGpsWfFL7B3ypm00ZA6crjJJLK_-j_H8bS_dnQbLFwyRcW67IXCs5sRkro71bRZv7L1WM - - // eventBus.on().listen((event) { - // if (firebaseMessaging != null) { - // firebaseMessaging.subscribeToTopic(event.topic); - // } - // }); - // eventBus.on().listen((event) { - // if (firebaseMessaging != null) { - // firebaseMessaging.unsubscribeFromTopic(event.topic); - // } - // }); - } - - initLocalNotification() async { - var initializationSettingsAndroid = new AndroidInitializationSettings('ic_launcher'); - var initializationSettingsIOS = new IOSInitializationSettings( - onDidReceiveLocalNotification: onDidReceiveLocalNotification); - var initializationSettings = new InitializationSettings( - android: initializationSettingsAndroid, - iOS: initializationSettingsIOS, - ); - await flutterLocalNotificationsPlugin.initialize(initializationSettings, - onSelectNotification: onSelectNotification); - } - - Future onSelectNotification(String payload, {bool replace=false}) async { - print('payload: $payload'); - if (payload != null && payload.isNotEmpty) { - Routes.router.navigateTo(store.state.context, payload, replace: replace); - } - } - -// initFirebaseMessaging() { -// if (Platform.isIOS) { -// iosPermission(); -// } -// firebaseMessaging.getToken().then((token) { -// print('FCM token: $token'); -// store.dispatch(UpdateFcmToken(token)); -// }); -// firebaseMessaging.configure( -// onMessage: (Map message) { -// print('FCM onMessage: $message'); -// // eventBus.fire(OnFcmReceived(message)); -// showNotificationWithDefaultSound(message); -// return; -// }, -// onBackgroundMessage: Platform.isIOS ? null : backgroundMessageHandler, -// onResume: (Map message) { -// print('FCM onResume: $message'); -// if (Platform.isAndroid) { -// if (message != null && message['data'] != null && message['data']['route'] != null) { -// notificationTapped = true; -// onSelectNotification(message['data']['route']); -// } -// } else { -// if (message != null && message['route'] != null) { -// notificationTapped = true; -// onSelectNotification(message['route']); -// } -// } -// return; -// }, -// onLaunch: (Map message) { -// print('FCM onLaunch: $message'); -// if (Platform.isAndroid) { -// if (message != null && message['data'] != null && message['data']['route'] != null) { -// notificationTapped = true; -// onSelectNotification(message['data']['route'], replace: true); -// } -// } else { -// if (message != null && message['route'] != null) { -// notificationTapped = true; -// onSelectNotification(message['route'], replace: true); -// } -// } -// return; -// }, -// ); -// } - - Future onDidReceiveLocalNotification(int id, String title, String body, String payload) async { - showDialog( - context: store.state.context, - builder: (BuildContext context) => CupertinoAlertDialog( - title: Text(title), - content: Text(body), - actions: [ - CupertinoDialogAction( - isDefaultAction: true, - child: Text(S.of(context).ok), - onPressed: () async { - Navigator.of(context, rootNavigator: true).pop(); - if (payload != null && payload.isNotEmpty) { - Routes.router.navigateTo(context, payload); - } - }, - ) - ], - ), - ); - } - - Future showNotificationWithDefaultSound(Map message) async { - var androidPlatformChannelSpecifics = new AndroidNotificationDetails( - 'channelId', - 'channelName', - 'channelDescription', - importance: Importance.max, - priority: Priority.high, - ); - var iOSPlatformChannelSpecifics = new IOSNotificationDetails(presentSound: true, badgeNumber: 1); - var platformChannelSpecifics = new NotificationDetails( - android: androidPlatformChannelSpecifics, - iOS: iOSPlatformChannelSpecifics, - ); - await flutterLocalNotificationsPlugin.show( - 0, - Platform.isAndroid ? message['notification']['title'] : message['title'], - Platform.isAndroid ? message['notification']['body'] : message['body'], - platformChannelSpecifics, - payload: Platform.isAndroid ? message['data']['route'] : message['route'], - ); - } - - // iosPermission() { - // firebaseMessaging.requestNotificationPermissions( - // const IosNotificationSettings( - // sound: true, - // badge: true, - // alert: true, - // ) - // ); - // firebaseMessaging.onIosSettingsRegistered.listen((IosNotificationSettings settings) { - // print('IOS settings registered: $settings'); - // }); - // } - - static Future backgroundMessageHandler(Map message) { - print('FCM background message handler: $message'); - return Future.value(); - } - - static Future getBox() async { - final dir = await getApplicationDocumentsDirectory(); - Hive.init(dir.path); - Box box = await Hive.openBox('app_data'); - return box; - } - - 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:')) { + static Widget showImage(String imageUrl, {double? width, double? height, + BoxFit? fit, Widget Function(BuildContext, String, dynamic)? errorWidget}) { + if (imageUrl.isNotEmpty && imageUrl.startsWith('https:')) { return CachedNetworkImage( imageUrl: imageUrl, width: width, height: width, fit: fit, - placeholder: (context, url) => Utils.imageLoadingIndicator(width: width, height: height), + placeholder: (context, url) => Utils.imageLoadingIndicator(width: width ?? 30, height: height ?? 30), errorWidget: errorWidget != null ? errorWidget : (context, url, error) { return Image.asset( 'assets/images/not_found.png', @@ -219,13 +58,13 @@ class Util { ); }, ); - } else if (imageUrl != null && imageUrl.isNotEmpty) { + } else if (imageUrl.isNotEmpty) { return Image.file( File(imageUrl), width: width, height: height, fit: fit, - errorBuilder: (BuildContext context, Object object, StackTrace stackTrace) { + errorBuilder: (BuildContext context, Object object, StackTrace? stackTrace) { return Image.asset( 'assets/images/not_found.png', width: width, @@ -319,14 +158,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 { @@ -456,18 +295,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}) async { var formData = FormData(); formData.fields.add(MapEntry("msg", msg)); formData.fields.add(MapEntry('id', id == null ? '0' : id.toString())); @@ -562,7 +401,7 @@ class Util { PaymentPlatform paymentPlatform, { bool googlePay=false, bool applePay=false, - StripePaymentMethod stripePaymentMethod, + StripePaymentMethod? stripePaymentMethod, }) { switch(paymentPlatform.code) { case Constants.PAYMENT_METHOD_CODE_SQUARE: @@ -587,7 +426,7 @@ class Util { StripePayment.setOptions( StripeOptions(publishableKey: paymentPlatform.publishableKey, merchantId: paymentPlatform.merchantId, - androidPayMode: paymentPlatform.publishableKey.contains('_test_') + androidPayMode: paymentPlatform.publishableKey!.contains('_test_') ? 'test' : 'production' ) @@ -595,14 +434,14 @@ class Util { StripePayment.paymentRequestWithNativePay( androidPayOptions: AndroidPayPaymentRequest( totalPrice: order.totalPrice.toStringAsFixed(2), - currencyCode: order.businessInfo.currency, + currencyCode: order.businessInfo!.currency, ), applePayOptions: ApplePayPaymentOptions( - currencyCode: order.businessInfo.currency, - countryCode: order.businessInfo.address.country, + currencyCode: order.businessInfo!.currency, + countryCode: order.businessInfo!.address.country, items: [ ApplePayItem( - label: order.businessInfo.name, + label: order.businessInfo!.name, amount: order.totalPrice.toStringAsFixed(2), ), ], @@ -633,7 +472,7 @@ class Util { ), ); if (paymentMethod != null) { - Utils.stripePaymentIntent(order, null, paymentMethod.id, paymentMethod.type, (response) { + Utils.stripePaymentIntent(order, null, paymentMethod.id!, paymentMethod.type!, (response) { if (response.data['status'] == Constants.STRIPE_STATUS_REQUIRES_CONFIRMATION) { StripePayment.confirmPaymentIntent( PaymentIntent( @@ -643,8 +482,8 @@ class Util { ).then((paymentIntentResult) { if (paymentIntentResult.status == Constants.STRIPE_STATUS_SUCCEDED) { Utils.stripeChargedSuccess(order, - paymentMethod.id, - paymentIntentResult.paymentIntentId, + paymentMethod.id!, + paymentIntentResult.paymentIntentId!, (response) { StripePayment.completeNativePayRequest().then((_) { eventBus.fire(OnOrderUpdated()); @@ -680,10 +519,10 @@ class Util { } } - static Future getBytesFromAsset(String path, int width) async { + static Future getBytesFromAsset(String path, int width) async { 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/utils/util_web.dart b/lib/utils/util_web.dart index 4f62cf1..b29e838 100644 --- a/lib/utils/util_web.dart +++ b/lib/utils/util_web.dart @@ -5,8 +5,6 @@ import 'dart:typed_data'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; -import 'package:hive/hive.dart'; -import 'package:hive_flutter/hive_flutter.dart'; import 'package:url_launcher/url_launcher.dart'; import '../constants.dart'; @@ -36,27 +34,21 @@ class Util { } - static Future getBox() async { - Hive.initFlutter(); - Box box = await Hive.openBox('wisetronic_app_data'); - 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}) { return Image.network(imageUrl, fit: fit, width: width, height: height, cacheWidth: width != null ? width.round() : null, cacheHeight: height != null ? height.round() : null, - loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent loadingProgress) { + loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) { if (loadingProgress == null) return child; return Center( child: Utils.imageLoadingIndicator(), ); }, - errorBuilder: (BuildContext context, Object object, StackTrace stackTrace) { + errorBuilder: (BuildContext context, Object object, StackTrace? stackTrace) { print('StackTrace: $stackTrace'); if (errorWidget != null) { return errorWidget(context, null, null); @@ -106,16 +98,16 @@ class Util { } void startFilePicker(BuildContext context, User user, {int commentId = -1, int orderId = 0}) async { - InputElement uploadInput = FileUploadInputElement(); + InputElement uploadInput = FileUploadInputElement() as InputElement; uploadInput.click(); uploadInput.onChange.listen((e) { final files = uploadInput.files; - if (files.length >= 1) { + if (files!.length >= 1) { final File file = files[0]; final FileReader reader = new FileReader(); reader.onLoadEnd.listen((e) { - uploadPicture(context, reader.result, file.name, user, commentId: commentId, orderId: orderId); + uploadPicture(context, reader.result as Uint8List, file.name, user, commentId: commentId, orderId: orderId); }); reader.onError.listen((e) { Fluttertoast.showToast( @@ -210,11 +202,11 @@ class Util { void startFilePicker2(BuildContext context, int imageId, OnGotFile onGotFile) async { final _image = await WebImagePicker().pickImage(); - onGotFile(imageId, _image.dataScheme); + onGotFile(imageId, _image!.dataScheme); } void 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())); @@ -252,7 +244,7 @@ class Util { PaymentPlatform paymentPlatform, { bool googlePay=false, bool applePay=false, - StripePaymentMethod stripePaymentMethod, + StripePaymentMethod? stripePaymentMethod, }) { switch(paymentPlatform.code) { case Constants.PAYMENT_METHOD_CODE_SQUARE: @@ -293,36 +285,36 @@ class Util { } class ImageInfo { - String name; - String data; - String dataScheme; - String path; + String name = ''; + String data = ''; + String dataScheme = ''; + String path = ''; } class WebImagePicker { - Future pickImage() async { + Future pickImage() async { print('pickImage'); final ImageInfo data = ImageInfo(); final FileUploadInputElement input = FileUploadInputElement(); - document.body.children.add(input); + document.body!.children.add(input); input..accept = 'image/*'; input.click(); await input.onChange.first; - if (input.files.isEmpty) return null; + if (input.files!.isEmpty) return null; final reader = FileReader(); - reader.readAsDataUrl(input.files[0]); + reader.readAsDataUrl(input.files![0]); await reader.onLoad.first; final encoded = reader.result as String; // remove data:image/*;base64 preambule final stripped = encoded.replaceFirst(RegExp(r'data:image/[^;]+;base64,'), ''); //final imageBase64 = base64.decode(stripped); - final imageName = input.files?.first?.name; - final imagePath = input.files?.first?.relativePath; - data.name = imageName; + final imageName = input.files?.first.name; + final imagePath = input.files?.first.relativePath; + data.name = imageName!; data.data = stripped; data.dataScheme = encoded; - data.path = imagePath; + data.path = imagePath!; return data; } } \ No newline at end of file diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index ee277c7..86d9351 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -8,7 +8,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_wisetronic/models/product.dart'; import 'package:fluttertoast/fluttertoast.dart'; -import 'package:hive/hive.dart'; import 'package:intl/intl.dart'; import 'package:path/path.dart' as path; import 'package:universal_io/io.dart'; @@ -28,6 +27,7 @@ import '../store/actions.dart'; import '../store/store.dart'; import 'http_util.dart'; import 'util_web.dart' if (dart.library.io) 'util_io.dart'; +import 'package:shared_preferences/shared_preferences.dart'; typedef void OnSuccess(Response response); typedef void OnError(dynamic error); @@ -37,16 +37,25 @@ typedef void OnOk(); typedef void OnLoadImageError(); class Utils { - static StreamSubscription onProductWillAddToCartSubscription; - static StreamSubscription onProductWillRemoveFromCartSubscription; + static final Utils _utils = Utils._internal(); + static SharedPreferences? prefs; + + static StreamSubscription? onProductWillAddToCartSubscription; + static StreamSubscription? onProductWillRemoveFromCartSubscription; + + factory Utils() { + return _utils; + } + Utils._internal(); init() async { + prefs = await SharedPreferences.getInstance(); onProductWillAddToCartSubscription = eventBus.on().listen((event) { - CartInfo cartInfo = + CartInfo? cartInfo = getCartInfoByBusiness(store.state.cartInfos, event.business); - if (cartInfo == null || cartInfo.productList.length == 0) { + if (cartInfo == null || cartInfo.productList!.length == 0) { cartInfo = CartInfo(); cartInfo.id = 0; cartInfo.amountPaid = 0.0; @@ -57,7 +66,7 @@ class Utils { id: 0, price: event.price, product: event.product, - name: event.product.name, + name: event.product.name!, description: event.description, quantity: 1.0); cartInfo.productList = [lineItem]; @@ -67,15 +76,15 @@ class Utils { eventBus.fire(new OnCartInfoUpdated()); print('#1'); } else { - if (event.product.productAttributes.length > 0) { + if (event.product.productAttributes!.length > 0) { CartLineItem lineItem = newCartLineItem( id: 0, price: event.price, product: event.product, - name: event.product.name, + name: event.product.name!, description: event.description, quantity: 1.0); - cartInfo.productList.add(lineItem); + cartInfo.productList!.add(lineItem); addSubproductToCard(cartInfo, lineItem); store.dispatch(new UpdateCartInfo(addCartInfoToCartInfoList( store.state.cartInfos, cartInfo))); @@ -83,8 +92,8 @@ class Utils { eventBus.fire(new OnCartInfoUpdated()); } else { int found = -1; - for (var i = 0; i < cartInfo.productList.length; i++) { - if (event.product.id == cartInfo.productList[i].product.id) { + for (var i = 0; i < cartInfo.productList!.length; i++) { + if (event.product.id == cartInfo.productList![i].product!.id) { found = i; break; } @@ -94,18 +103,18 @@ class Utils { id: 0, price: event.price, product: event.product, - name: event.product.name, + name: event.product.name!, description: event.description, quantity: 1.0); - cartInfo.productList.add(lineItem); + cartInfo.productList!.add(lineItem); addSubproductToCard(cartInfo, lineItem); store.dispatch(new UpdateCartInfo(addCartInfoToCartInfoList( store.state.cartInfos, cartInfo))); print('#3'); eventBus.fire(new OnCartInfoUpdated()); } else { - if (cartInfo.productList[found].quantity + 1.0 > - event.product.leftNum) { + if (cartInfo.productList![found].quantity! + 1.0 > + event.product.leftNum!) { // Fluttertoast.showToast( // msg: S.of(context).product_insufficient, // toastLength: Toast.LENGTH_SHORT, @@ -113,8 +122,8 @@ class Utils { // backgroundColor: Colors.red, // textColor: Colors.white); } else { - cartInfo.productList[found].quantity += 1; - addSubproductQty(cartInfo, cartInfo.productList[found]); + cartInfo.productList![found].quantity = cartInfo.productList![found].quantity! + 1; + addSubproductQty(cartInfo, cartInfo.productList![found]); store.dispatch(new UpdateCartInfo( addCartInfoToCartInfoList( store.state.cartInfos, cartInfo))); @@ -127,41 +136,41 @@ class Utils { }); onProductWillRemoveFromCartSubscription = eventBus.on().listen((event) { - CartInfo cartInfo = + CartInfo? cartInfo = getCartInfoByBusiness(store.state.cartInfos, event.business); if (cartInfo != null) { - if (cartInfo.productList.length > 0) { + if (cartInfo.productList!.length > 0) { if (event.productListIndex != -1) { - if (cartInfo.productList[event.productListIndex].quantity <= 1) { - String uuid = cartInfo.productList[event.productListIndex].uuid; - cartInfo.productList.removeAt(event.productListIndex); + if (cartInfo.productList![event.productListIndex].quantity! <= 1) { + String uuid = cartInfo.productList![event.productListIndex].uuid!; + cartInfo.productList!.removeAt(event.productListIndex); removeSubproduct(cartInfo, uuid); } else { - cartInfo.productList[event.productListIndex].quantity -= 1; - addSubproductQty(cartInfo, cartInfo.productList[event.productListIndex], remove: true); + cartInfo.productList![event.productListIndex].quantity = cartInfo.productList![event.productListIndex].quantity! - 1; + addSubproductQty(cartInfo, cartInfo.productList![event.productListIndex], remove: true); } } else { int productListIndex = -1; - for (var i = 0; i < cartInfo.productList.length; i++) { - if (cartInfo.productList[i].product.id == event.product.id) { + for (var i = 0; i < cartInfo.productList!.length; i++) { + if (cartInfo.productList![i].product!.id == event.product.id) { productListIndex = i; break; } } if (productListIndex != -1) { - if (cartInfo.productList[productListIndex].quantity <= 1) { - String uuid = cartInfo.productList[productListIndex].uuid; - cartInfo.productList.removeAt(productListIndex); + if (cartInfo.productList![productListIndex].quantity! <= 1) { + String uuid = cartInfo.productList![productListIndex].uuid!; + cartInfo.productList!.removeAt(productListIndex); removeSubproduct(cartInfo, uuid); } else { - cartInfo.productList[productListIndex].quantity -= 1; - addSubproductQty(cartInfo, cartInfo.productList[productListIndex], remove: true); + cartInfo.productList![productListIndex].quantity = cartInfo.productList![productListIndex].quantity! - 1; + addSubproductQty(cartInfo, cartInfo.productList![productListIndex], remove: true); } } } } - if (cartInfo.productList.length <= 0) { + if (cartInfo.productList!.length <= 0) { store.dispatch(UpdateCartInfo(removeCartInfoFromCartInfoList( store.state.cartInfos, cartInfo))); } else { @@ -211,7 +220,7 @@ class Utils { return false; } - static Map stringToJson(String string) { + static Map? stringToJson(String? string) { if (string == null || string.isEmpty) { return null; } @@ -244,10 +253,6 @@ class Utils { return platformName; } - static Future getBox() async { - return Util.getBox(); - } - static Widget imageLoadingIndicator( {double width = 30.0, double height = 30.0}) { return SizedBox( @@ -365,7 +370,7 @@ class Utils { ); } - static showLoadingDialog(BuildContext context, {String message}) { + static showLoadingDialog(BuildContext context, {String? message}) { showDialog( context: context, barrierDismissible: false, @@ -468,46 +473,45 @@ class Utils { } static void getCurrentUser() { - getBox().then((box) { - int userId = box.get(Constants.KEY_USER_ID, defaultValue: 0); - String accessToken = - box.get(Constants.KEY_ACCESS_TOKEN, defaultValue: ''); - if (userId == 0 || accessToken.isEmpty) { - eventBus.fire(new OnGetCurrentUserFailed(Error())); - } else { - HttpUtil.httpGet( - 'v1/users/$userId', - queryParameters: {}, - businessId: Constants.BUSINESS_ID, - ).then((value) { - User user = User.fromJson(value); - store.dispatch(UpdateCurrentUser(user)); - eventBus.fire(OnCurrentUserUpdated()); - }).catchError((err) { - eventBus.fire(new OnGetCurrentUserFailed(err)); - }); - } - }).catchError((err) { - eventBus.fire(new OnGetCurrentUserFailed(err)); - }); + if (store.state.user != null) { + eventBus.fire(OnCurrentUserUpdated()); + return; + } + int? userId = prefs?.getInt(Constants.KEY_USER_ID) ?? 0; + String? accessToken = prefs?.getString(Constants.KEY_ACCESS_TOKEN) ?? ''; + if (userId == 0 || accessToken.isEmpty) { + eventBus.fire(new OnGetCurrentUserFailed(Error())); + } else { + HttpUtil.httpGet( + 'v1/users/$userId', + queryParameters: {}, + businessId: Constants.BUSINESS_ID, + ).then((value) { + User user = User.fromJson(value); + store.dispatch(UpdateCurrentUser(user)); + eventBus.fire(OnCurrentUserUpdated()); + }).catchError((err) { + eventBus.fire(new OnGetCurrentUserFailed(err)); + }); + } } static void showMessageDialog(BuildContext context, dynamic error, - {String title, List actions, OnOk onOk}) { + {String? title, List? actions, OnOk? onOk}) { String message = ''; print('error $error'); - if (error is DioError && error.response != null) { - if (error.response.data['message'] != null) { - message = error.response.data['message']; - } else if (error.response.data['error'] != null) { - if (error.response.data['error'] is String) { - message = error.response.data['error']; - } else if (error.response.data['error']['errmsg'] != null) { - message = error.response.data['error']['errmsg']; - } else if (error.response.data['error']['message'] != null) { - message = error.response.data['error']['message']; + if (error is DioException && error.response != null) { + if (error.response!.data['message'] != null) { + message = error.response!.data['message']; + } else if (error.response!.data['error'] != null) { + if (error.response!.data['error'] is String) { + message = error.response!.data['error']; + } else if (error.response!.data['error']['errmsg'] != null) { + message = error.response!.data['error']['errmsg']; + } else if (error.response!.data['error']['message'] != null) { + message = error.response!.data['error']['message']; } else { - message = error.response.data.toString(); + message = error.response!.data.toString(); } } } else if (error is String) { @@ -540,20 +544,15 @@ class Utils { } static Future> getLastVisit() async { - Box box = await getBox(); List lastVisit = - json.decode(box.get(Constants.KEY_LAST_VISIT, defaultValue: '[]')); + json.decode(prefs?.getString(Constants.KEY_LAST_VISIT) ?? '[]'); List lv = lastVisit.map((e) => e as int).toList(); store.dispatch(UpdateLastVisit(lv)); return lv; } static void saveLastVisit(List lastVisit) { - getBox().then((box) { - box.put(Constants.KEY_LAST_VISIT, lastVisit.toString()); - }).catchError((error) { - print('Error occurred: $error'); - }); + prefs?.setString(Constants.KEY_LAST_VISIT, lastVisit.toString()); } static String utcDatetimeStringToLocalDatetimeString( @@ -656,26 +655,26 @@ class Utils { } } - static CartInfo getCartInfoByBusiness( - List cartInfos, Business business) { + static CartInfo? getCartInfoByBusiness( + List? cartInfos, Business business) { if (cartInfos == null || cartInfos.length <= 0) { return null; } for (var i = 0; i < cartInfos.length; i++) { - if (cartInfos[i].businessInfo.id == business.id) { + if (cartInfos[i].businessInfo!.id == business.id) { return cartInfos[i]; } } return null; } - static CartInfo getCartInfoByBusinessId( - List cartInfos, int businessId) { + static CartInfo? getCartInfoByBusinessId( + List? cartInfos, int businessId) { if (cartInfos == null || cartInfos.length <= 0) { return null; } for (var i = 0; i < cartInfos.length; i++) { - if (cartInfos[i].businessInfo.id == businessId) { + if (cartInfos[i].businessInfo!.id == businessId) { return cartInfos[i]; } } @@ -683,13 +682,13 @@ class Utils { } static List addCartInfoToCartInfoList( - List cartInfos, CartInfo cartInfo) { + List? cartInfos, CartInfo cartInfo) { if (cartInfos == null || cartInfos.length <= 0) { cartInfos = [cartInfo]; } else { bool found = false; for (var i = 0; i < cartInfos.length; i++) { - if (cartInfos[i].businessInfo.id == cartInfo.businessInfo.id) { + if (cartInfos[i].businessInfo!.id == cartInfo.businessInfo!.id) { cartInfos[i] = cartInfo; found = true; break; @@ -699,22 +698,19 @@ class Utils { cartInfos.add(cartInfo); } } - Utils.getBox().then((box) { - box.put(Constants.KEY_CARTINFOS, cartInfos.toString()); - }).catchError((error) { - print('Error occurred: $error'); - }); + prefs?.setString(Constants.KEY_CARTINFOS, cartInfos.toString()); return cartInfos; } static List removeCartInfoFromCartInfoList( - List cartInfos, CartInfo cartInfo) { + List? cartInfos, CartInfo? cartInfo) { if (cartInfos == null || cartInfos.length <= 0 || cartInfo == null) { + prefs?.setString(Constants.KEY_CARTINFOS, cartInfos.toString()); return []; } int removeIndex = -1; for (var i = 0; i < cartInfos.length; i++) { - if (cartInfo.businessInfo.id == cartInfos[i].businessInfo.id) { + if (cartInfo.businessInfo!.id == cartInfos[i].businessInfo!.id) { removeIndex = i; break; } @@ -722,17 +718,13 @@ class Utils { if (removeIndex != -1) { cartInfos.removeAt(removeIndex); } - getBox().then((box) { - box.put(Constants.KEY_CARTINFOS, cartInfos.toString()); - }).catchError((error) { - print('Error occurred: $error'); - }); + prefs?.setString(Constants.KEY_CARTINFOS, cartInfos.toString()); return cartInfos; } static void clearCart(BuildContext context, CartInfo cartInfo, - {OnComplete onComplete}) { - if (cartInfo != null && cartInfo.productList.length > 0) { + {OnComplete? onComplete}) { + if (cartInfo != null && cartInfo.productList!.length > 0) { showDialog( context: context, builder: (BuildContext context) { @@ -766,7 +758,7 @@ class Utils { } static void requireLogin(BuildContext context, - {String returnUrl, bool replace = true, int delayMilliseconds = 400}) { + {String? returnUrl, bool replace = true, int delayMilliseconds = 400}) { Future.delayed(Duration(milliseconds: delayMilliseconds), () { if (returnUrl != null) { store.dispatch(UpdateRedirectRoute(returnUrl)); @@ -775,9 +767,9 @@ class Utils { }); } - static String getFirstNumberFromString(String numString) { + static String? getFirstNumberFromString(String numString) { final intInStr = RegExp(r'\d+'); - return intInStr.firstMatch(numString).group(0); + return intInStr.firstMatch(numString)?.group(0); } static void loadProducts(int businessId, int categoryId, int page, bool more, @@ -845,7 +837,7 @@ class Utils { } } - static String getWeekDayName(BuildContext context, int timestamp, bool shortName) { + static String? getWeekDayName(BuildContext context, int timestamp, bool shortName) { DateTime date = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000); switch(date.weekday) { case 1: @@ -854,61 +846,54 @@ class Utils { } else { return S.of(context).monday; } - break; case 2: if (shortName) { return S.of(context).tue; } else { return S.of(context).tuesday; } - break; case 3: if (shortName) { return S.of(context).wed; } else { return S.of(context).wednesday; } - break; case 4: if (shortName) { return S.of(context).thu; } else { return S.of(context).thursday; } - break; case 5: if (shortName) { return S.of(context).fri; } else { return S.of(context).friday; } - break; case 6: if (shortName) { return S.of(context).sat; } else { return S.of(context).saturday; } - break; case 7: if (shortName) { return S.of(context).sun; } else { return S.of(context).sunday; } - break; } } - static void stripePaymentIntent(Order order, String customerId, String paymentMethodId, String cardType, + static void stripePaymentIntent(Order order, String? customerId, String paymentMethodId, String cardType, OnSuccess onSuccess, OnError onError, { - String cardBrand, - String cardCountry, - int cardExpMonth, - int cardExpYear, - String cardFunding, - String cardLast4, + String? cardBrand, + String? cardCountry, + int? cardExpMonth, + int? cardExpYear, + String? cardFunding, + String? cardLast4, }) { HttpUtil.httpPost('v1/stripe-payment-intent', @@ -919,12 +904,12 @@ class Utils { 'customer_id': customerId == null ? '' : customerId, 'payment_method_id': paymentMethodId, 'payment_method_type': cardType, - 'card_brand': cardBrand, - 'card_country': cardCountry, - 'card_exp_month': cardExpMonth, - 'card_exp_year': cardExpYear, - 'card_funding': cardFunding, - 'card_last4': cardLast4, + 'card_brand': cardBrand ?? '', + 'card_country': cardCountry ?? '', + 'card_exp_month': cardExpMonth ?? 0, + 'card_exp_year': cardExpYear ?? 0, + 'card_funding': cardFunding ?? '', + 'card_last4': cardLast4 ?? '', }, isFormData: true, ).catchError(onError); @@ -945,8 +930,8 @@ class Utils { static int getProductLineInOrder(CartInfo cartInfo) { int qty = 0; - for (CartLineItem lineItem in cartInfo.productList) { - if (lineItem.product.id != null) { + for (CartLineItem lineItem in cartInfo.productList!) { + if (lineItem.product?.id != null) { qty += 1; } } @@ -954,10 +939,10 @@ class Utils { } static void orderAgain(BuildContext context, CartInfo cartInfo) { - cartInfo.productList.removeWhere((element) => element.product == null || element.product.id == null); + cartInfo.productList!.removeWhere((element) => element.product == null || element.product!.id == null); store.dispatch(UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo))); eventBus.fire(new OnCartInfoUpdated()); - Routes.router.navigateTo(context, '/checkout/${cartInfo.businessInfo.id}'); + Routes.router.navigateTo(context, '/checkout/${cartInfo.businessInfo!.id}'); } static String getOrderStatus(BuildContext context, int statusCode) { @@ -978,42 +963,42 @@ class Utils { } static CartLineItem newCartLineItem( - {int id, - double price, - Product product, - String name, - String description, - double quantity, - String parentUuid, + {int? id, + double? price, + Product? product, + String? name, + String? description, + double? quantity, + String? parentUuid, }) { CartLineItem lineItem = CartLineItem(); lineItem.unitPrice = price; lineItem.product = product; - lineItem.name = product.name; + lineItem.name = product?.name ?? ''; lineItem.description = description; lineItem.quantity = quantity; - lineItem.parentUuid = parentUuid; + lineItem.parentUuid = parentUuid ?? ''; return lineItem; } static void addSubproductToCard(CartInfo cartInfo, CartLineItem lineItem) { - if (lineItem.product.subproducts.length > 0) { - for (int j = 0; j < lineItem.product.subproducts.length; j++) { - cartInfo.productList.add( + if (lineItem.product!.subproducts!.length > 0) { + for (int j = 0; j < lineItem.product!.subproducts!.length; j++) { + cartInfo.productList!.add( newCartLineItem( id: 0, price: 0.0, product: Product( - lineItem.product.subproducts[j].product.id, - lineItem.product.businessId, - lineItem.product.subproducts[j].product.name, - lineItem.product.subproducts[j].product.price, - lineItem.product.subproducts[j].product.description, - lineItem.product.subproducts[j].product.image, - lineItem.product.subproducts[j].product.productAttributes + lineItem.product!.subproducts![j].product.id, + lineItem.product!.businessId!, + lineItem.product!.subproducts![j].product.name, + lineItem.product!.subproducts![j].product.price, + lineItem.product!.subproducts![j].product.description, + lineItem.product!.subproducts![j].product.image, + lineItem.product!.subproducts![j].product.productAttributes ), - name: lineItem.product.subproducts[j].product.name, - description: lineItem.product.subproducts[j].product.description, + name: lineItem.product!.subproducts![j].product.name, + description: lineItem.product!.subproducts![j].product.description, quantity: 1.0, parentUuid: lineItem.uuid ) @@ -1024,16 +1009,16 @@ class Utils { static void addSubproductQty(CartInfo cartInfo, CartLineItem lineItem, {bool remove = false}) { - if (lineItem.product.subproducts.length > 0) { - for (var i = 0; i < cartInfo.productList.length; i++) { - CartLineItem lineItem1 = cartInfo.productList[i]; + if (lineItem.product!.subproducts!.length > 0) { + for (var i = 0; i < cartInfo.productList!.length; i++) { + CartLineItem lineItem1 = cartInfo.productList![i]; if (lineItem1.parentUuid == lineItem.uuid) { - for (var j = 0; j < lineItem.product.subproducts.length; j++) { - if (lineItem.product.subproducts[j].product.id == lineItem1.product.id) { + for (var j = 0; j < lineItem.product!.subproducts!.length; j++) { + if (lineItem.product!.subproducts![j].product.id == lineItem1.product!.id) { if (remove) { - lineItem1.quantity -= lineItem.product.subproducts[j].quantity; + lineItem1.quantity = lineItem1.quantity! - lineItem.product!.subproducts![j].quantity; } else { - lineItem1.quantity += lineItem.product.subproducts[j].quantity; + lineItem1.quantity = lineItem1.quantity! + lineItem.product!.subproducts![j].quantity; } break; } @@ -1044,7 +1029,7 @@ class Utils { } static void removeSubproduct(CartInfo cartInfo, String uuid) { - cartInfo.productList.removeWhere((element) => element.parentUuid == uuid); + cartInfo.productList!.removeWhere((element) => element.parentUuid == uuid); } static void openEmail(String email) async { @@ -1069,7 +1054,7 @@ class Utils { } } - static Widget buildLine(String name, dynamic value, {double nameSize, double valueSize}) { + static Widget buildLine(String name, dynamic value, {double? nameSize, double? valueSize}) { Row row = Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -1119,7 +1104,7 @@ class Utils { } class RuntimeError extends Error { - final int code; + final int? code; final String message; RuntimeError(this.message, {this.code}); String toString() => "Runtime Error: $message"; diff --git a/lib/widgets/desktop/desktop_buy_service.dart b/lib/widgets/desktop/desktop_buy_service.dart index 68db0fa..bf667ee 100644 --- a/lib/widgets/desktop/desktop_buy_service.dart +++ b/lib/widgets/desktop/desktop_buy_service.dart @@ -13,9 +13,9 @@ import '../../widgets/general/breadcrumbs.dart'; import '../../widgets/general/navigationbar.dart'; class DesktopBuyService extends StatefulWidget { - final Map data; + final Map? data; - const DesktopBuyService(this.data, {Key key}) + const DesktopBuyService(this.data, {Key? key}) : super(key: key); @override diff --git a/lib/widgets/desktop/desktop_edit_address.dart b/lib/widgets/desktop/desktop_edit_address.dart index bc3704d..ae45191 100644 --- a/lib/widgets/desktop/desktop_edit_address.dart +++ b/lib/widgets/desktop/desktop_edit_address.dart @@ -5,7 +5,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_wisetronic/widgets/general/breadcrumbs.dart'; import 'package:fluttertoast/fluttertoast.dart'; -import 'package:gender_selection/gender_selection.dart'; +import 'package:gender_picker/gender_picker.dart'; +import 'package:gender_picker/source/enums.dart'; import '../../constants.dart'; import '../../events/eventbus.dart'; @@ -20,10 +21,9 @@ import '../../utils/utils.dart'; import '../../widgets/general/navigationbar.dart'; class DesktopEditAddress extends StatefulWidget { - final Key key; - final Address address; + final Address? address; final int businessId; - const DesktopEditAddress(this.address, {this.key, int businessId}) : + const DesktopEditAddress(this.address, {Key? key, int? businessId}) : businessId = businessId ?? Constants.BUSINESS_ID; @override @@ -45,12 +45,12 @@ class DesktopEditAddressState extends State { final emailController = TextEditingController(); final faxController = TextEditingController(); - String country; - Gender _selectedGender; + String? country; + Gender? _selectedGender; - String _selectedProvince; + String? _selectedProvince; - bool showLoading; + bool showLoading = false; double sideSpace = 0; double mainSpace = 1200; @@ -105,8 +105,8 @@ class DesktopEditAddressState extends State { .of(context) .contact_name, ), - validator: (String value) { - if (value + validator: (String? value) { + if (value == null || value .trim() .isEmpty) { return S @@ -117,27 +117,25 @@ class DesktopEditAddressState extends State { }, ), ), - GenderSelection( - maleText: S - .of(context) - .mr, - femaleText: S - .of(context) - .ms, - selectedGenderIconBackgroundColor: Colors.indigo, - checkIconAlignment: Alignment.bottomRight, - selectedGenderCheckIcon: Icons.check, - onChanged: (Gender gender) { + GenderPickerWithImage( + onChanged: (Gender? gender) { _selectedGender = gender; }, - equallyAligned: true, - animationDuration: Duration(milliseconds: 400), - isCircular: true, - isSelectedGenderIconCircular: true, - opacityOfGradient: 0.6, - padding: const EdgeInsets.all(3.0), - size: 50, + maleText: S.of(context).mr, + femaleText: S.of(context).ms, selectedGender: _selectedGender, + showOtherGender: false, + verticalAlignedText: false, + selectedGenderTextStyle: TextStyle( + color: Color(0xFF8b32a8), fontWeight: FontWeight.bold), + unSelectedGenderTextStyle: TextStyle( + color: Colors.white, fontWeight: FontWeight.normal), + equallyAligned: true, + animationDuration: Duration(milliseconds: 200), + isCircular: true, + opacityOfGradient: 0.5, + padding: const EdgeInsets.all(3), + size: 50, ), Container( padding: EdgeInsets.only( @@ -160,8 +158,8 @@ class DesktopEditAddressState extends State { .of(context) .mobile_phone_number, ), - validator: (String value) { - if (value + validator: (String? value) { + if (value == null || value .trim() .isEmpty) { return S @@ -192,8 +190,8 @@ class DesktopEditAddressState extends State { .of(context) .street_line_1, ), - validator: (String value) { - if (value + validator: (String? value) { + if (value == null || value .trim() .isEmpty) { return S @@ -246,8 +244,8 @@ class DesktopEditAddressState extends State { .of(context) .city, ), - validator: (String value) { - if (value + validator: (String? value) { + if (value == null || value .trim() .isEmpty) { return S @@ -316,8 +314,8 @@ class DesktopEditAddressState extends State { .of(context) .postal_code, ), - validator: (String value) { - if (value + validator: (String? value) { + if (value == null || value .trim() .isEmpty) { return S @@ -361,8 +359,8 @@ class DesktopEditAddressState extends State { .of(context) .email, ), - validator: (String value) { - if (value.isNotEmpty && !EmailValidator.validate(value)) { + validator: (String? value) { + if (value != null && value.isNotEmpty && !EmailValidator.validate(value)) { return S .of(context) .email_is_not_valid; @@ -496,29 +494,29 @@ class DesktopEditAddressState extends State { super.initState(); setState(() { showLoading = false; - _selectedProvince = widget.address.state; - cityController.text = widget.address.city; - postalCodeController.text = widget.address.zip; - streetLine1Controller.text = widget.address.addressLine1; - streetLine2Controller.text = widget.address.addressLine2; - _selectedGender = widget.address.gender == 1 ? Gender.Male : Gender.Female; - country = widget.address.country; - contactNameController.text = widget.address.contactName; - phoneController.text = widget.address.phone; - emailController.text = widget.address.email; - faxController.text = widget.address.fax; + _selectedProvince = widget.address?.state; + cityController.text = widget.address?.city ?? ''; + postalCodeController.text = widget.address?.zip ?? ''; + streetLine1Controller.text = widget.address?.addressLine1 ?? ''; + streetLine2Controller.text = widget.address?.addressLine2 ?? ''; + _selectedGender = widget.address?.gender == 1 ? Gender.Male : Gender.Female; + country = widget.address?.country; + contactNameController.text = widget.address?.contactName ?? ''; + phoneController.text = widget.address?.phone ?? ''; + emailController.text = widget.address?.email ?? ''; + faxController.text = widget.address?.fax ?? ''; }); } void _saveEditAddress() { - final FormState form = _formKey.currentState; - if (form.validate()) { + final FormState? form = _formKey.currentState; + if (form != null && form.validate()) { if (mounted) { setState(() { showLoading = true; }); } - HttpUtil.httpPatch('v1/addresses/${widget.address.id}', (response) { + HttpUtil.httpPatch('v1/addresses/${widget.address?.id}', (response) { if (mounted) { setState(() { showLoading = false; @@ -532,7 +530,7 @@ class DesktopEditAddressState extends State { } }, body: { - 'id': widget.address.id, + 'id': widget.address?.id, 'name': contactNameController.text.trim(), 'address_line1': streetLine1Controller.text.trim(), 'address_line2': streetLine2Controller.text.trim(), @@ -562,7 +560,7 @@ class DesktopEditAddressState extends State { showLoading = true; }); } - HttpUtil.httpDelete('v1/addresses/${widget.address.id}', (response) { + HttpUtil.httpDelete('v1/addresses/${widget.address?.id}', (response) { if (mounted) { setState(() { showLoading = false; diff --git a/lib/widgets/desktop/desktop_index_main_content_1.dart b/lib/widgets/desktop/desktop_index_main_content_1.dart index 92994e1..2432c7b 100644 --- a/lib/widgets/desktop/desktop_index_main_content_1.dart +++ b/lib/widgets/desktop/desktop_index_main_content_1.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:flutter_wisetronic/generated/l10n.dart'; class DesktopIndexMainContent1 extends StatefulWidget { - final String message; - const DesktopIndexMainContent1(this.message, {Key key}) : super(key: key); + final String? message; + const DesktopIndexMainContent1(this.message, {Key? key}) : super(key: key); @override State createState() { @@ -37,7 +36,7 @@ class DesktopIndexMainContent1State extends State { padding: EdgeInsets.symmetric(vertical: 30.0, horizontal: 30.0), child: Container( child: Text( - widget.message, + widget.message ?? '', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, diff --git a/lib/widgets/desktop/desktop_index_main_content_2.dart b/lib/widgets/desktop/desktop_index_main_content_2.dart index 3a03ad7..7ec6bff 100644 --- a/lib/widgets/desktop/desktop_index_main_content_2.dart +++ b/lib/widgets/desktop/desktop_index_main_content_2.dart @@ -5,8 +5,8 @@ import '../../widgets/general/text_link.dart'; import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dart'; class DesktopIndexMainContent2 extends StatefulWidget { - final Map content; - const DesktopIndexMainContent2(this.content, {Key key}) : super(key: key); + final Map? content; + const DesktopIndexMainContent2(this.content, {Key? key}) : super(key: key); @override State createState() { @@ -54,7 +54,7 @@ class DesktopIndexMainContent2State extends State { Container( padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0), child: Text( - '${widget.content['minipos']}', + '${widget.content?['minipos']}', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, @@ -66,7 +66,7 @@ class DesktopIndexMainContent2State extends State { width: mainSpace / 2 - 100.0, padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0), child: Text( - '${widget.content['point_of_sale_system_solution']}', + '${widget.content?['point_of_sale_system_solution']}', style: TextStyle( fontSize: 15.0, color: Colors.grey, @@ -80,7 +80,7 @@ class DesktopIndexMainContent2State extends State { Container( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Util.showImage( - 'https:${widget.content['minipos_image']['image']}', + 'https:${widget.content?['minipos_image']['image']}', fit: BoxFit.fitWidth ), ), @@ -101,7 +101,7 @@ class DesktopIndexMainContent2State extends State { Container( padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0), child: Text( - '${widget.content['igoshow']}', + '${widget.content?['igoshow']}', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, @@ -113,7 +113,7 @@ class DesktopIndexMainContent2State extends State { width: mainSpace / 2 - 100.0, padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0), child: Text( - '${widget.content['igoshow_solution']}', + '${widget.content?['igoshow_solution']}', style: TextStyle( fontSize: 15.0, color: Colors.grey, @@ -127,7 +127,7 @@ class DesktopIndexMainContent2State extends State { Container( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Util.showImage( - 'https:${widget.content['igoshow_image']['image']}', + 'https:${widget.content?['igoshow_image']['image']}', fit: BoxFit.fitWidth ), ), @@ -149,7 +149,7 @@ class DesktopIndexMainContent2State extends State { Column col = Column( children: [], ); - for (int i = 0; i < (widget.content['minipos_features'] as List).length; i++) { + for (int i = 0; i < (widget.content?['minipos_features'] as List).length; i++) { col.children.add(Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -166,7 +166,7 @@ class DesktopIndexMainContent2State extends State { width: width - 40.0, padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0), child: Text( - '${(widget.content['minipos_features'] as List)[i]}', + '${(widget.content?['minipos_features'] as List)[i]}', style: TextStyle( color: Colors.black54, ), @@ -195,7 +195,7 @@ class DesktopIndexMainContent2State extends State { Column col = Column( children: [], ); - for (int i = 0; i < (widget.content['igoshow_features'] as List).length; i++) { + for (int i = 0; i < (widget.content?['igoshow_features'] as List).length; i++) { col.children.add(Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -212,7 +212,7 @@ class DesktopIndexMainContent2State extends State { width: width - 40.0, padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0), child: Text( - '${(widget.content['igoshow_features'] as List)[i]}', + '${(widget.content?['igoshow_features'] as List)[i]}', style: TextStyle( color: Colors.black54, ), diff --git a/lib/widgets/desktop/desktop_index_main_content_3.dart b/lib/widgets/desktop/desktop_index_main_content_3.dart index ced65b8..fc832a2 100644 --- a/lib/widgets/desktop/desktop_index_main_content_3.dart +++ b/lib/widgets/desktop/desktop_index_main_content_3.dart @@ -6,8 +6,8 @@ import 'package:flutter_wisetronic/widgets/general/text_link.dart'; import '../../constants.dart'; class DesktopIndexMainContent3 extends StatefulWidget { - final Map content; - const DesktopIndexMainContent3(this.content, {Key key}) : super(key: key); + final Map? content; + const DesktopIndexMainContent3(this.content, {Key? key}) : super(key: key); @override State createState() { diff --git a/lib/widgets/desktop/desktop_navigationbar.dart b/lib/widgets/desktop/desktop_navigationbar.dart index 51206ab..0191f4d 100644 --- a/lib/widgets/desktop/desktop_navigationbar.dart +++ b/lib/widgets/desktop/desktop_navigationbar.dart @@ -14,12 +14,12 @@ import '../../widgets/general/breadcrumbs.dart'; import '../../widgets/general/navigationbar.dart'; class DesktopNavigationBar extends StatefulWidget { - final bool hasBack; - final List breadCrumbs; - final Widget shoppingCart; - final OnBackPress onBackPress; + final bool? hasBack; + final List? breadCrumbs; + final Widget? shoppingCart; + final OnBackPress? onBackPress; - const DesktopNavigationBar({Key key, this.hasBack, this.breadCrumbs, + const DesktopNavigationBar({Key? key, this.hasBack, this.breadCrumbs, this.shoppingCart, this.onBackPress}) : super(key: key); @override @@ -30,13 +30,13 @@ class DesktopNavigationBar extends StatefulWidget { } class DesktopNavigationBarState extends State { - User _user; + User? _user; @override Widget build(BuildContext context) { Widget sc = SizedBox.shrink(); if (widget.shoppingCart != null) { - sc = widget.shoppingCart; + sc = widget.shoppingCart!; } Widget breadCrumbBar = SizedBox.shrink(); if (widget.breadCrumbs != null && widget.breadCrumbs.length > 0) { @@ -51,8 +51,8 @@ class DesktopNavigationBarState extends State { Expanded( child: BreadCrumbs( widget.hasBack ?? false, - onBackPress: widget.onBackPress, - breadCrumbs: widget.breadCrumbs, + onBackPress: widget.onBackPress!, + breadCrumbs: widget.breadCrumbs!, ), ), sc, diff --git a/lib/widgets/desktop/desktop_new_address.dart b/lib/widgets/desktop/desktop_new_address.dart index 5080060..9df8dc4 100644 --- a/lib/widgets/desktop/desktop_new_address.dart +++ b/lib/widgets/desktop/desktop_new_address.dart @@ -2,7 +2,8 @@ import 'package:email_validator/email_validator.dart'; import 'package:flutter/material.dart'; import 'package:flutter_wisetronic/widgets/general/breadcrumbs.dart'; -import 'package:gender_selection/gender_selection.dart'; +import 'package:gender_picker/gender_picker.dart'; +import 'package:gender_picker/source/enums.dart'; import '../../constants.dart'; import '../../generated/l10n.dart'; @@ -14,10 +15,9 @@ import '../../utils/http_util.dart'; import '../../widgets/general/navigationbar.dart'; class DesktopNewAddress extends StatefulWidget { - final Key key; - final LocatedAddress locatedAddress; - final int businessId; - const DesktopNewAddress({this.key, this.locatedAddress, this.businessId}) : super(key: key); + final LocatedAddress? locatedAddress; + final int? businessId; + const DesktopNewAddress({Key? key, this.locatedAddress, this.businessId}) : super(key: key); @override State createState() { @@ -39,9 +39,9 @@ class DesktopNewAddressState extends State { final faxController = TextEditingController(); String country = 'CA'; - Gender _selectedGender; + Gender? _selectedGender; - String _selectedProvince; + String? _selectedProvince; double sideSpace = 0; double mainSpace = 1200; @@ -97,31 +97,33 @@ class DesktopNewAddressState extends State { ), labelText: S.of(context).contact_name, ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).contact_name_is_required; } return null; }, ), ), - GenderSelection( - maleText: S.of(context).mr, - femaleText: S.of(context).ms, - selectedGenderIconBackgroundColor: Colors.indigo, - checkIconAlignment: Alignment.bottomRight, - selectedGenderCheckIcon: Icons.check, - onChanged: (Gender gender) { + GenderPickerWithImage( + onChanged: (Gender? gender) { _selectedGender = gender; }, - equallyAligned: true, - animationDuration: Duration(milliseconds: 400), - isCircular: true, - isSelectedGenderIconCircular: true, - opacityOfGradient: 0.6, - padding: const EdgeInsets.all(3.0), - size: 50, + maleText: S.of(context).mr, + femaleText: S.of(context).ms, selectedGender: _selectedGender, + showOtherGender: false, + verticalAlignedText: false, + selectedGenderTextStyle: TextStyle( + color: Color(0xFF8b32a8), fontWeight: FontWeight.bold), + unSelectedGenderTextStyle: TextStyle( + color: Colors.white, fontWeight: FontWeight.normal), + equallyAligned: true, + animationDuration: Duration(milliseconds: 200), + isCircular: true, + opacityOfGradient: 0.5, + padding: const EdgeInsets.all(3), + size: 50, ), Container( padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 16.0, bottom: 0.0), @@ -141,8 +143,8 @@ class DesktopNewAddressState extends State { ), labelText: S.of(context).mobile_phone_number, ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).mobile_phone_number_is_required; } return null; @@ -166,8 +168,8 @@ class DesktopNewAddressState extends State { ), labelText: S.of(context).street_line_1, ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).street_line_1_is_required; } return null; @@ -210,8 +212,8 @@ class DesktopNewAddressState extends State { ), labelText: S.of(context).city, ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).city_is_required; } return null; @@ -256,8 +258,8 @@ class DesktopNewAddressState extends State { ), labelText: S.of(context).postal_code, ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).postal_code_is_required; } return null; @@ -291,8 +293,8 @@ class DesktopNewAddressState extends State { ), labelText: S.of(context).email, ), - validator: (String value) { - if (value.isNotEmpty && !EmailValidator.validate(value)) { + validator: (String? value) { + if (value == null || value.isNotEmpty && !EmailValidator.validate(value)) { return S.of(context).email_is_not_valid; } return null; @@ -377,15 +379,15 @@ class DesktopNewAddressState extends State { super.initState(); setState(() { if (widget.locatedAddress != null) { - if (provinces.contains(widget.locatedAddress.province)) { - _selectedProvince = widget.locatedAddress.province; + if (provinces.contains(widget.locatedAddress?.province)) { + _selectedProvince = widget.locatedAddress?.province; } - 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.streetName; + 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!.streetName; } else { _selectedProvince = 'Ontario'; } @@ -395,11 +397,11 @@ class DesktopNewAddressState extends State { } void _saveNewAddress() { - final FormState form = _formKey.currentState; - if (form.validate()) { + final FormState? form = _formKey.currentState; + if (form != null && form.validate()) { HttpUtil.httpPost('v1/addresses', (response) { - if (widget.businessId > 0) { + if (widget.businessId != null && widget.businessId! > 0) { Routes.router.navigateTo(context, '/checkout/${widget.businessId}', replace: true); } else { Routes.router.navigateTo(context, '/my-addresses/${widget.businessId}', replace: true); diff --git a/lib/widgets/desktop/desktop_stripe_pay_web.dart b/lib/widgets/desktop/desktop_stripe_pay_web.dart index 6940334..958dbb8 100644 --- a/lib/widgets/desktop/desktop_stripe_pay_web.dart +++ b/lib/widgets/desktop/desktop_stripe_pay_web.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:stripe_sdk/stripe_sdk.dart'; -import 'package:stripe_sdk/stripe_sdk_ui.dart'; +import '../../vendor/stripe_sdk/lib/stripe_sdk_ui.dart'; +import '../../utils/mini_stripe_api.dart'; import '../../constants.dart'; import '../../events/eventbus.dart'; @@ -20,11 +20,10 @@ import '../../widgets/general/navigationbar.dart'; class DesktopStripePayWeb extends StatefulWidget { - final Key key; final Order order; final PaymentPlatform paymentPlatform; - final StripePaymentMethod stripePaymentMethod; - const DesktopStripePayWeb(this.order, this.paymentPlatform, {this.key, this.stripePaymentMethod}); + final StripePaymentMethod? stripePaymentMethod; + const DesktopStripePayWeb(this.order, this.paymentPlatform, {Key? key, this.stripePaymentMethod}); @override State createState() { @@ -39,9 +38,9 @@ class DesktopStripePayWebState extends State { final formKey = GlobalKey(); final card = StripeCard(); - CardForm form; + CardForm? form; - bool isSubmitting; + bool isSubmitting = false; double sideSpace = 0; double mainSpace = 1200; @@ -69,23 +68,37 @@ class DesktopStripePayWebState extends State { form = CardForm(card: card, formKey: formKey, displayPostalCode: false,); body = ListView( children: [ - form, + form!, Container( padding: EdgeInsets.only(top: 20.0, bottom: 20.0, right: 16.0), alignment: Alignment.centerRight, - child: ElevatedButton( + child: ElevatedButton.icon( style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Colors.green, + foregroundColor: Colors.white, + padding: + EdgeInsets.only(left: 32, right: 32, top: 20, bottom: 20), + elevation: 2.0, + shape: new RoundedRectangleBorder( + borderRadius: new BorderRadius.circular(10.0), + ), ), - child: Text( - S.of(context).submit, + icon: Icon( + Icons.check, + size: 32.0, + color: Colors.yellow, + ), + label: Text( + S.of(context).pay, style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, color: Colors.white, ), ), onPressed: () { - if (formKey.currentState.validate()) { - formKey.currentState.save(); + if (formKey.currentState != null && formKey.currentState!.validate()) { + formKey.currentState!.save(); _paymentRequestWithCard(context); } else { ScaffoldMessenger.of(context).showSnackBar( @@ -131,7 +144,7 @@ class DesktopStripePayWebState extends State { void initState() { super.initState(); isSubmitting = false; - StripeApi.init(widget.paymentPlatform.publishableKey); + MiniStripeApi.init(widget.paymentPlatform.publishableKey!); } SnackBar messageSnackBar(BuildContext context, String message) { @@ -160,12 +173,12 @@ class DesktopStripePayWebState extends State { } _paymentWithPaymentMethod(BuildContext context) async { - Utils.stripePaymentIntent(widget.order, widget.stripePaymentMethod.customerId, - widget.stripePaymentMethod.paymentMethodId, - widget.stripePaymentMethod.paymentMethodType, (response) async { + Utils.stripePaymentIntent(widget.order, widget.stripePaymentMethod?.customerId, + widget.stripePaymentMethod!.paymentMethodId, + widget.stripePaymentMethod!.paymentMethodType, (response) async { if (response.data['status'] == Constants.STRIPE_STATUS_REQUIRES_CONFIRMATION) { - await StripeApi.instance.confirmPaymentIntent( + await MiniStripeApi.instance.confirmPaymentIntent( response.data[Constants.STRIPE_CLIENT_SECRET], data: { 'payment_method': response.data['payment_method'], @@ -173,7 +186,7 @@ class DesktopStripePayWebState extends State { ).then((result2) { if (result2['status'] == Constants.STRIPE_STATUS_SUCCEDED) { Utils.stripeChargedSuccess(widget.order, - widget.stripePaymentMethod.paymentMethodId, + widget.stripePaymentMethod!.paymentMethodId, result2['id'], (response) { if (isSubmitting) { Navigator.of(context).pop(); @@ -198,11 +211,11 @@ class DesktopStripePayWebState extends State { _paymentRequestWithCard(BuildContext context) async { isSubmitting = true; Utils.showSubmitDialog(context); - await StripeApi.instance.createPaymentMethodFromCard(card) + await MiniStripeApi.instance.createPaymentMethodFromCard(card) .then((result) { Utils.stripePaymentIntent(widget.order, null, result['id'], result['type'], (response) async { if (response.data['status'] == Constants.STRIPE_STATUS_REQUIRES_CONFIRMATION) { - await StripeApi.instance.confirmPaymentIntent( + await MiniStripeApi.instance.confirmPaymentIntent( response.data[Constants.STRIPE_CLIENT_SECRET], data: { 'payment_method': response.data['payment_method'], diff --git a/lib/widgets/general/add_remove_button.dart b/lib/widgets/general/add_remove_button.dart index fe407bb..c42701b 100644 --- a/lib/widgets/general/add_remove_button.dart +++ b/lib/widgets/general/add_remove_button.dart @@ -1,6 +1,6 @@ -import 'package:badges/badges.dart'; +import 'package:badges/badges.dart' as badges; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; @@ -17,16 +17,16 @@ import '../../store/store.dart'; import '../../utils/utils.dart'; class AddRemoveButton extends StatefulWidget { - final Product product; + final Product? product; final Business business; - final bool addOnly; - final int cartLineItemIndex; - final bool addToBasket; - final bool onHovor; + final bool? addOnly; + final int? cartLineItemIndex; + final bool? addToBasket; + final bool? onHovor; AddRemoveButton({ this.product, - this.business, + required this.business, this.addOnly = false, this.cartLineItemIndex = -1, this.addToBasket = false, @@ -40,7 +40,7 @@ class AddRemoveButton extends StatefulWidget { } class AddRemoveButtonState extends State { - int _qty; + 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; + CartInfo? cartInfo; GlobalKey startKey = GlobalKey(); @@ -59,14 +59,14 @@ class AddRemoveButtonState extends State { @override Widget build(BuildContext context) { - if (widget.product.leftNum == null) { + if (widget.product?.leftNum == null) { _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( @@ -100,19 +100,19 @@ class AddRemoveButtonState extends State { ), ); } - if (widget.addToBasket) { + if (widget.addToBasket!) { _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 (_qty > 0) { - return Badge( + if (_qty! > 0) { + return badges.Badge( badgeContent: Text( '$_qty', style: TextStyle( @@ -120,14 +120,17 @@ class AddRemoveButtonState extends State { fontSize: 17.0, ), ), - padding: EdgeInsets.all(10), - position: BadgePosition.topEnd(top: -15, end: -10), - badgeColor: Colors.lightBlueAccent, + badgeStyle: badges.BadgeStyle( + padding: EdgeInsets.all(10), + badgeColor: Colors.lightBlueAccent, + ), + position: badges.BadgePosition.topEnd(top: -15, end: -10), child: ElevatedButton.icon( style: ElevatedButton.styleFrom( - primary: Colors.redAccent, - onPrimary: Colors.white, - padding: EdgeInsets.only(left: 32, right: 32, top: 20, bottom: 20), + backgroundColor: Colors.redAccent, + foregroundColor: Colors.white, + padding: + EdgeInsets.only(left: 32, right: 32, top: 20, bottom: 20), elevation: 2.0, shape: new RoundedRectangleBorder( borderRadius: new BorderRadius.circular(10.0), @@ -154,7 +157,7 @@ class AddRemoveButtonState extends State { } else { return ElevatedButton.icon( style: ElevatedButton.styleFrom( - primary: Colors.redAccent, + backgroundColor: Colors.redAccent, padding: EdgeInsets.only(left: 32, right: 32, top: 20, bottom: 20), elevation: 2.0, shape: new RoundedRectangleBorder( @@ -179,7 +182,7 @@ class AddRemoveButtonState extends State { }, ); } - } else if (widget.addOnly) { + } else if (widget.addOnly!) { return Container( key: startKey, padding: EdgeInsets.all(0.0), @@ -197,15 +200,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) { + if (widget.product!.productAttributes != null && + widget.product!.productAttributes!.length > 0 && widget.cartLineItemIndex == -1) { return new Row( key: startKey, crossAxisAlignment: CrossAxisAlignment.end, @@ -219,13 +222,13 @@ class AddRemoveButtonState extends State { style: new TextStyle( fontSize: 13.0, fontWeight: FontWeight.bold, - color: _qty > 0 ? qtyFontColor : zeroFontColor + color: _qty! > 0 ? qtyFontColor : zeroFontColor ), ), ), padding: EdgeInsets.all(5.0).copyWith(left: 10.0, right: 10.0), decoration: BoxDecoration( - color: _qty > 0 ? qtyColor : zeroColor, + color: _qty! > 0 ? qtyColor : zeroColor, shape: BoxShape.rectangle, borderRadius: BorderRadius.only( topLeft: Radius.circular(10.0), @@ -242,7 +245,7 @@ class AddRemoveButtonState extends State { ], ); } else { - if (!widget.onHovor && _qty == 0) { + if (!widget.onHovor! && _qty == 0) { return SizedBox.shrink(); } return new Row( @@ -258,13 +261,13 @@ class AddRemoveButtonState extends State { style: new TextStyle( fontSize: 13.0, fontWeight: FontWeight.bold, - color: _qty > 0 ? qtyFontColor : zeroFontColor + color: _qty! > 0 ? qtyFontColor : zeroFontColor ), ), ), padding: EdgeInsets.all(5.0).copyWith(left: 10.0, right: 10.0), decoration: BoxDecoration( - color: _qty > 0 ? qtyColor : zeroColor, + color: _qty! > 0 ? qtyColor : zeroColor, shape: BoxShape.rectangle, borderRadius: BorderRadius.only( topLeft: Radius.circular(10.0), @@ -299,7 +302,7 @@ class AddRemoveButtonState extends State { ), ), onTap: () { - if (_qty > 0) { + if (_qty! > 0) { _removeFromCart(context); } }, @@ -312,7 +315,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,23 +324,23 @@ 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 = cartInfo!.productList![widget.cartLineItemIndex!].quantity! + 1.0; + Utils.addSubproductQty(cartInfo!, cartInfo!.productList![widget.cartLineItemIndex!]); store.dispatch(UpdateCartInfo( - Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo))); + 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) => new AttributeSelection( - product: widget.product, business: widget.business, startKey: startKey,)), + product: widget.product!, business: widget.business, startKey: startKey,)), ); } else { - eventBus.fire(new OnProductWillAddToCart(widget.product, {}, - widget.product.price, widget.product.description, + eventBus.fire(new OnProductWillAddToCart(widget.product!, {}, + widget.product!.price!, widget.product!.description!, widget.business, buttonKey: startKey)); } } @@ -345,7 +348,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) { @@ -375,23 +378,23 @@ class AddRemoveButtonState extends State { } } else { eventBus.fire(new OnProductWillRemoveFromCart( - widget.product, -1, widget.business)); + widget.product!, -1, widget.business)); } } void _removeCartLineItem() { - if (cartInfo.productList[widget.cartLineItemIndex].quantity <= 1) { - String uuid = cartInfo.productList[widget.cartLineItemIndex].uuid; - cartInfo.productList.removeAt(widget.cartLineItemIndex); - Utils.removeSubproduct(cartInfo, uuid); + 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 = 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))); + store.dispatch(new UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo!))); } eventBus.fire(new OnCartInfoUpdated()); } diff --git a/lib/widgets/general/animation_point_manager.dart b/lib/widgets/general/animation_point_manager.dart index 6b98a0b..bd4a26e 100644 --- a/lib/widgets/general/animation_point_manager.dart +++ b/lib/widgets/general/animation_point_manager.dart @@ -5,23 +5,23 @@ import 'popup_animation_widget.dart'; class AnimationPointManager { List list = []; - static AnimationController controller1; - static AnimationController controller2; + static AnimationController? controller1; + static AnimationController? controller2; Future addParabolicAniamtion({ - @required TickerProvider vsync, - @required GlobalKey stackKey, - @required GlobalKey startKey, - @required GlobalKey endKey, - @required Duration duration, - @required AnimationStatusListener statusListener, + required TickerProvider vsync, + required GlobalKey stackKey, + required GlobalKey startKey, + required GlobalKey endKey, + required Duration duration, + required AnimationStatusListener statusListener, Color color = Colors.red, double size = 20, Offset startAdjustOffset = Offset.zero, Offset endAdjustOffset = Offset.zero, }) async { controller1 = createController(vsync, duration); - Animation animation = createAnimation(controller1); + Animation animation = createAnimation(controller1); AnimatedWidget animatedWidget = ParabolicAnimationWidget( animation: animation, @@ -37,9 +37,9 @@ class AnimationPointManager { statusListener(AnimationStatus.dismissed); try { - await controller1.forward().orCancel; + await controller1?.forward().orCancel; list.remove(animatedWidget); - controller1.dispose(); + controller1?.dispose(); print('Controller1 disposed'); } on TickerCanceled { print("Ticker Canceled"); @@ -51,31 +51,31 @@ class AnimationPointManager { } Future addPopupAniamtion({ - @required TickerProvider vsync, - @required GlobalKey stackKey, - @required GlobalKey startKey, - @required Widget child, - Duration duration, + required TickerProvider vsync, + required GlobalKey stackKey, + required GlobalKey startKey, + required Widget child, + required Duration duration, Offset popupOffset = Offset.zero, - AnimationStatusListener statusListener, + AnimationStatusListener? statusListener, }) async { controller2 = createController(vsync, duration); AnimatedWidget animatedWidget = PopupAnimationWidget( - animation: controller2.view, + animation: controller2!.view, stackKey: stackKey, startKey: startKey, child: child, popupOffset: popupOffset, ); list.add(animatedWidget); - statusListener(AnimationStatus.dismissed); + if (statusListener != null) statusListener(AnimationStatus.dismissed); try { - await controller2.forward().orCancel; - await controller2.reverse().orCancel; + await controller2?.forward().orCancel; + await controller2?.reverse().orCancel; list.remove(animatedWidget); - controller2.dispose(); + controller2?.dispose(); print('Controller2 disposed'); } on TickerCanceled { print("Ticker Canceled"); @@ -83,7 +83,7 @@ class AnimationPointManager { print('Error: $error'); } - statusListener(AnimationStatus.completed); + if (statusListener != null) statusListener(AnimationStatus.completed); } static AnimationController createController( diff --git a/lib/widgets/general/attribute/check_options.dart b/lib/widgets/general/attribute/check_options.dart index 1280837..c74a00f 100644 --- a/lib/widgets/general/attribute/check_options.dart +++ b/lib/widgets/general/attribute/check_options.dart @@ -14,7 +14,7 @@ import 'rules.dart'; import 'options_base.dart'; class CheckOptions extends OptionsBase { - CheckOptions({@required Product product, @required int index, @required Map selections}) + CheckOptions({required Product product, required int index, required Map selections}) : super(product: product, index: index, selections: selections); @override @@ -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,25 +95,25 @@ 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; }); - eventBus.fire(new OnAttributeSelectionsChanged(selections)); + eventBus.fire(new OnAttributeSelectionsChanged(selections!)); } Widget _getOptionWidget() { @@ -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); + Map? attrExtraJson = Utils.stringToJson( + product!.productAttributes![index!].extra); if (attrExtraJson != null) { var selectLimitIfFieldEqualsTo = Rule.getRule( attrExtraJson, Rule.RULE_SELECT_LIMIT_IF_FIELD_EQUALS_TO); @@ -147,15 +147,15 @@ 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(); } - } else if (Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY]).length > 0) { - 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]]; + } else if (Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY]).length > 0) { + 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,15 +168,15 @@ 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(); } - } else if (Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY]).length > 0) { - 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]]; + } else if (Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY]).length > 0) { + 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(); } @@ -187,7 +187,7 @@ class CheckOptionsState extends OptionsBaseState { } for (var i = 0; i < productOptions.length; i++) { - Map extraJson = Utils.stringToJson( + Map? extraJson = Utils.stringToJson( productOptions[i].extra); if (extraJson != null) { Map exclusiveRule = Rule.getRule( @@ -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; @@ -251,7 +251,7 @@ class CheckOptionsState extends OptionsBaseState { bool disabled = optDisabled; bool check = _checkOptionIsCheck(productOption.name); - Map extraJson = Utils.stringToJson(productOption.extra); + Map? extraJson = Utils.stringToJson(productOption.extra); // Utils.jsonPrettyPrint(extraJson); double extraAdjustAmount = 0.0; @@ -262,13 +262,13 @@ class CheckOptionsState extends OptionsBaseState { if (sizeBaseAdjustment is List) { for (var i = 0; i < (sizeBaseAdjustment as List).length; i++) { Map sizeBaseAdjustment1 = sizeBaseAdjustment[i]; - List attValues = Utils.getSelectedAttributeValue(selections, sizeBaseAdjustment1[Rule.RULE_KEY_FIELD_KEY]); + List attValues = Utils.getSelectedAttributeValue(selections!, sizeBaseAdjustment1[Rule.RULE_KEY_FIELD_KEY]); if (attValues.length > 0 && sizeBaseAdjustment1.containsKey(attValues[0])) { extraAdjustAmount += sizeBaseAdjustment1[attValues[0]]; } } } else { - List attValues = Utils.getSelectedAttributeValue(selections, sizeBaseAdjustment[Rule.RULE_KEY_FIELD_KEY]); + List attValues = Utils.getSelectedAttributeValue(selections!, sizeBaseAdjustment[Rule.RULE_KEY_FIELD_KEY]); if (attValues.length > 0 && sizeBaseAdjustment.containsKey(attValues[0])) { extraAdjustAmount += sizeBaseAdjustment[attValues[0]]; } @@ -282,7 +282,7 @@ class CheckOptionsState extends OptionsBaseState { for (var i = 0; i < (disabledRule as List).length; i++) { Map disabledRule1 = disabledRule[i]; List attValues = Utils.getSelectedAttributeValue( - selections, disabledRule1[Rule.RULE_KEY_FIELD_KEY]); + selections!, disabledRule1[Rule.RULE_KEY_FIELD_KEY]); if (attValues.length > 0 && disabledRule1.containsKey(attValues[0])) { disabled = true; @@ -301,7 +301,7 @@ class CheckOptionsState extends OptionsBaseState { } } else { List attValues = Utils.getSelectedAttributeValue( - selections, disabledRule[Rule.RULE_KEY_FIELD_KEY]); + selections!, disabledRule[Rule.RULE_KEY_FIELD_KEY]); if (attValues.length > 0) { for (String s in attValues) { if (disabledRule.containsKey(s) && disabledRule[s]) { diff --git a/lib/widgets/general/attribute/options_base.dart b/lib/widgets/general/attribute/options_base.dart index b9d5de9..d35673d 100644 --- a/lib/widgets/general/attribute/options_base.dart +++ b/lib/widgets/general/attribute/options_base.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:flutter_wisetronic/models/product.dart'; +import '../../../models/product.dart'; typedef void OnOptionTapped(String name, int quantity, double adjustAmount); @@ -9,16 +9,16 @@ abstract class OptionsBase extends StatefulWidget { final Product product; final int index; final Map selections; - OptionsBase({@required Product product, @required int index, @required Map selections}) + OptionsBase({required Product product, required int index, required Map selections}) : product = product, index = index, selections = selections; } abstract class OptionsBaseState extends State { - Product product; - Map selections; - int index; + Product? product; + Map? selections; + 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..fd84c8d 100644 --- a/lib/widgets/general/attribute/qty_options.dart +++ b/lib/widgets/general/attribute/qty_options.dart @@ -14,7 +14,7 @@ import 'options_base.dart'; import 'rules.dart'; class QtyOptions extends OptionsBase { - QtyOptions({@required Product product, @required int index, @required Map selections}) + QtyOptions({required Product product, required int index, required Map selections}) : super(product: product, index: index, selections: selections); @override @@ -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,38 +86,38 @@ 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; }); - eventBus.fire(new OnAttributeSelectionsChanged(selections)); + eventBus.fire(new OnAttributeSelectionsChanged(selections!)); } Widget _getOptionWidget() { @@ -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())) { - Map attrExtraJson = Utils.stringToJson( - product.productAttributes[index].extra); + if (selections!.containsKey(product!.productAttributes![index!].name.toUpperCase())) { + Map? attrExtraJson = Utils.stringToJson( + product!.productAttributes![index!].extra); if (attrExtraJson != null) { var selectLimitIfFieldEqualsTo = Rule.getRule( attrExtraJson, Rule.RULE_SELECT_LIMIT_IF_FIELD_EQUALS_TO); @@ -155,15 +155,15 @@ 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(); } - } else if (Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY]).length > 0) { - 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]]; + } else if (Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY]).length > 0) { + 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,15 +176,15 @@ 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(); } - } else if (Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY]).length > 0) { - 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]]; + } else if (Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY]).length > 0) { + 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,7 +195,7 @@ class QtyOptionsState extends OptionsBaseState { } for (var i = 0; i < productOptions.length; i++) { - Map extraJson = Utils.stringToJson( + Map? extraJson = Utils.stringToJson( productOptions[i].extra); if (extraJson != null) { Map exclusiveRule = Rule.getRule( @@ -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; @@ -259,7 +259,7 @@ class QtyOptionsState extends OptionsBaseState { bool disabled = optDisabled; bool check = _checkOptionIsCheck(productOption.name); - Map extraJson = Utils.stringToJson(productOption.extra); + Map? extraJson = Utils.stringToJson(productOption.extra); // Utils.jsonPrettyPrint(extraJson); double extraAdjustAmount = 0.0; @@ -270,13 +270,13 @@ class QtyOptionsState extends OptionsBaseState { if (sizeBaseAdjustment is List) { for (var i = 0; i < (sizeBaseAdjustment as List).length; i++) { Map sizeBaseAdjustment1 = sizeBaseAdjustment[i]; - List attValues = Utils.getSelectedAttributeValue(selections, sizeBaseAdjustment1[Rule.RULE_KEY_FIELD_KEY]); + List attValues = Utils.getSelectedAttributeValue(selections!, sizeBaseAdjustment1[Rule.RULE_KEY_FIELD_KEY]); if (attValues.length > 0 && sizeBaseAdjustment1.containsKey(attValues[0])) { extraAdjustAmount += sizeBaseAdjustment1[attValues[0]]; } } } else { - List attValues = Utils.getSelectedAttributeValue(selections, sizeBaseAdjustment[Rule.RULE_KEY_FIELD_KEY]); + List attValues = Utils.getSelectedAttributeValue(selections!, sizeBaseAdjustment[Rule.RULE_KEY_FIELD_KEY]); if (attValues.length > 0 && sizeBaseAdjustment.containsKey(attValues[0])) { extraAdjustAmount += sizeBaseAdjustment[attValues[0]]; } @@ -290,7 +290,7 @@ class QtyOptionsState extends OptionsBaseState { for (var i = 0; i < (disabledRule as List).length; i++) { Map disabledRule1 = disabledRule[i]; List attValues = Utils.getSelectedAttributeValue( - selections, disabledRule1[Rule.RULE_KEY_FIELD_KEY]); + selections!, disabledRule1[Rule.RULE_KEY_FIELD_KEY]); if (attValues.length > 0 && disabledRule1.containsKey(attValues[0])) { disabled = true; @@ -309,7 +309,7 @@ class QtyOptionsState extends OptionsBaseState { } } else { List attValues = Utils.getSelectedAttributeValue( - selections, disabledRule[Rule.RULE_KEY_FIELD_KEY]); + selections!, disabledRule[Rule.RULE_KEY_FIELD_KEY]); if (attValues.length > 0) { for (String s in attValues) { if (disabledRule.containsKey(s) && disabledRule[s]) { diff --git a/lib/widgets/general/attribute/radio_options.dart b/lib/widgets/general/attribute/radio_options.dart index d05027e..2331845 100644 --- a/lib/widgets/general/attribute/radio_options.dart +++ b/lib/widgets/general/attribute/radio_options.dart @@ -14,7 +14,7 @@ import 'options_base.dart'; import 'rules.dart'; class RadioOptions extends OptionsBase { - RadioOptions({@required Product product, @required int index, @required Map selections}) + RadioOptions({required Product product, required int index, required Map selections}) : super(product: product, index: index, selections: selections); @override @@ -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,24 +85,24 @@ 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]; } } - Map extraJson = Utils.stringToJson(productOption.extra); + Map? extraJson = Utils.stringToJson(productOption.extra); if (extraJson != null) { Map exclusiveRule = Rule.getRule( extraJson, Rule.RULE_EXCLUSIVE_SELECTION); if (exclusiveRule != null) { if (_checkOptionIsCheck(productOption.name)) { - setOptionsStateDisabled(product.productAttributes[index].name, false); + setOptionsStateDisabled(product!.productAttributes![index!].name, false); } } } @@ -110,7 +110,7 @@ class RadioOptionsState extends OptionsBaseState { setState(() { selections = cloneSelections; }); - eventBus.fire(new OnAttributeSelectionsChanged(selections)); + eventBus.fire(new OnAttributeSelectionsChanged(selections!)); } Widget _getOptionWidget() { @@ -118,42 +118,42 @@ 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++) { - Map extraJson = Utils.stringToJson(productOptions[i].extra); + Map? extraJson = Utils.stringToJson(productOptions[i].extra); if (extraJson != null) { Map exclusiveRule = Rule.getRule( 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; @@ -163,7 +163,7 @@ class RadioOptionsState extends OptionsBaseState { bool disabled = optDisabled; bool check = _checkOptionIsCheck(productOption.name); - Map extraJson = Utils.stringToJson(productOption.extra); + Map? extraJson = Utils.stringToJson(productOption.extra); // Utils.jsonPrettyPrint(extraJson); double extraAdjustAmount = 0.0; @@ -174,13 +174,13 @@ class RadioOptionsState extends OptionsBaseState { if (sizeBaseAdjustment is List) { for (var i = 0; i < (sizeBaseAdjustment as List).length; i++) { Map sizeBaseAdjustment1 = sizeBaseAdjustment[i]; - List attValues = Utils.getSelectedAttributeValue(selections, sizeBaseAdjustment1[Rule.RULE_KEY_FIELD_KEY]); + List attValues = Utils.getSelectedAttributeValue(selections!, sizeBaseAdjustment1[Rule.RULE_KEY_FIELD_KEY]); if (attValues.length > 0 && sizeBaseAdjustment1.containsKey(attValues[0])) { extraAdjustAmount += sizeBaseAdjustment1[attValues[0]]; } } } else { - List attValues = Utils.getSelectedAttributeValue(selections, sizeBaseAdjustment[Rule.RULE_KEY_FIELD_KEY]); + List attValues = Utils.getSelectedAttributeValue(selections!, sizeBaseAdjustment[Rule.RULE_KEY_FIELD_KEY]); if (attValues.length > 0 && sizeBaseAdjustment.containsKey(attValues[0])) { extraAdjustAmount += sizeBaseAdjustment[attValues[0]]; } @@ -194,7 +194,7 @@ class RadioOptionsState extends OptionsBaseState { for (var i = 0; i < (disabledRule as List).length; i++) { Map disabledRule1 = disabledRule[i]; List attValues = Utils.getSelectedAttributeValue( - selections, disabledRule1[Rule.RULE_KEY_FIELD_KEY]); + selections!, disabledRule1[Rule.RULE_KEY_FIELD_KEY]); if (attValues.length > 0 && disabledRule1.containsKey(attValues[0])) { disabled = true; @@ -213,7 +213,7 @@ class RadioOptionsState extends OptionsBaseState { } } else { List attValues = Utils.getSelectedAttributeValue( - selections, disabledRule[Rule.RULE_KEY_FIELD_KEY]); + selections!, disabledRule[Rule.RULE_KEY_FIELD_KEY]); if (attValues.length > 0) { for (String s in attValues) { if (disabledRule.containsKey(s) && disabledRule[s]) { diff --git a/lib/widgets/general/bottom_nav.dart b/lib/widgets/general/bottom_nav.dart index 4d4ce6d..d774641 100644 --- a/lib/widgets/general/bottom_nav.dart +++ b/lib/widgets/general/bottom_nav.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; class BottomNav extends StatefulWidget { - const BottomNav({Key key}) : super(key: key); + const BottomNav({Key? key}) : super(key: key); @override State createState() { diff --git a/lib/widgets/general/breadcrumbs.dart b/lib/widgets/general/breadcrumbs.dart index e45edcf..1b67597 100644 --- a/lib/widgets/general/breadcrumbs.dart +++ b/lib/widgets/general/breadcrumbs.dart @@ -7,10 +7,10 @@ import '../../routes.dart'; import 'navigationbar.dart'; class BreadCrumbs extends StatelessWidget { - final List breadCrumbs; + final List? breadCrumbs; final bool hasBack; - final OnBackPress onBackPress; - const BreadCrumbs(this.hasBack, {this.breadCrumbs, Key key, this.onBackPress}) : super(key: key); + final OnBackPress? onBackPress; + const BreadCrumbs(this.hasBack, {this.breadCrumbs, Key? key, this.onBackPress}) : super(key: key); @override Widget build(BuildContext context) { @@ -49,17 +49,17 @@ class BreadCrumbs extends StatelessWidget { )); } if (breadCrumbs != null) { - for (int i = 0; i < breadCrumbs.length; i++) { - BreadCrumb breadCrumb = breadCrumbs[i]; + for (int i = 0; i < breadCrumbs!.length; i++) { + BreadCrumb breadCrumb = breadCrumbs![i]; if (breadCrumb.text == null && breadCrumb.item != null) { if (breadCrumb.onTap == null) { - widgets.add(breadCrumb.item); + widgets.add(breadCrumb.item!); } else { widgets.add(MouseRegion( cursor: SystemMouseCursors.click, child: GestureDetector( - child: breadCrumb.item, - onTap: breadCrumb.onTap, + child: breadCrumb.item!, + onTap: breadCrumb.onTap as GestureTapCallback?, ), )); } @@ -94,7 +94,7 @@ class BreadCrumbs extends StatelessWidget { color: Colors.blueAccent, ), Text( - breadCrumb.text, + breadCrumb.text ?? '', style: TextStyle( color: Colors.blueAccent, fontSize: 14.0, @@ -103,7 +103,7 @@ class BreadCrumbs extends StatelessWidget { ], ) : Text( - breadCrumb.text, + breadCrumb.text ?? '', style: TextStyle( color: Colors.blueAccent, fontSize: 14.0, @@ -113,7 +113,7 @@ class BreadCrumbs extends StatelessWidget { ], ), onTap: () { - Routes.router.navigateTo(context, breadCrumb.route); + Routes.router.navigateTo(context, breadCrumb.route ?? ''); }, ), ), @@ -145,7 +145,7 @@ class BreadCrumbs extends StatelessWidget { color: Colors.lightBlueAccent, ), Text( - breadCrumb.text, + breadCrumb.text ?? '', style: TextStyle( color: Colors.black54, fontSize: 14.0, @@ -155,7 +155,7 @@ class BreadCrumbs extends StatelessWidget { ], ) : Text( - breadCrumb.text, + breadCrumb.text ?? '', style: TextStyle( color: Colors.black54, fontSize: 14.0, @@ -184,11 +184,11 @@ class BreadCrumbs extends StatelessWidget { } class BreadCrumb { - final String text; - final String route; - final IconData icon; - final Widget item; - final Function onTap; + final String? text; + final String? route; + final IconData? icon; + final Widget? item; + final Function? onTap; BreadCrumb(this.text, this.route, {this.icon, this.item, this.onTap}); } \ No newline at end of file diff --git a/lib/widgets/general/carousel.dart b/lib/widgets/general/carousel.dart index e239e1e..dda0bfe 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 = false, Duration duration = const Duration(seconds: 2), Duration animationDuration = const Duration(milliseconds: 1000), }) @@ -17,11 +17,11 @@ class Carousel extends StatefulWidget { duration = duration, animationDuration = animationDuration; - final double height; - final List pages; - final bool autoPlay; - final Duration duration; - final Duration animationDuration; + final double? height; + final List? pages; + final bool? autoPlay; + final Duration? duration; + final Duration? animationDuration; @override createState() => new CarouselState(); @@ -30,7 +30,7 @@ class Carousel extends StatefulWidget { class CarouselState extends State { final _pageController = new PageController(); - Timer _timer; + Timer? _timer; int _currentPage = 0; bool reverse = false; GlobalKey _indicatorStateKey = new GlobalKey(); @@ -38,13 +38,13 @@ class CarouselState extends State { @override void initState() { super.initState(); - if (widget.autoPlay) { - _timer = new Timer.periodic(widget.duration, (timer) { + if (widget.autoPlay!) { + _timer = new Timer.periodic(widget.duration!, (timer) { _pageController.animateToPage(_currentPage, - duration: widget.animationDuration, curve: Curves.linear); + duration: widget.animationDuration!, curve: Curves.linear); if (!reverse) { _currentPage += 1; - if (_currentPage == widget.pages.length) { + if (_currentPage == widget.pages?.length) { _currentPage -= 1; reverse = true; } @@ -61,9 +61,9 @@ class CarouselState extends State { @override void dispose() { - _pageController?.dispose(); + _pageController.dispose(); if (_timer != null) { - _timer.cancel(); + _timer!.cancel(); } super.dispose(); } @@ -77,10 +77,10 @@ class CarouselState extends State { color: Style.backgroundColor, child: new PageView( controller: _pageController, - children: widget.pages, + children: widget.pages!, onPageChanged: (index) { _currentPage = index; - _indicatorStateKey.currentState.changeIndex(index); + _indicatorStateKey.currentState?.changeIndex(index); }, ), ), @@ -91,7 +91,7 @@ class CarouselState extends State { child: new Align( child: new Indicator( key: _indicatorStateKey, - count: widget.pages.length, + count: widget.pages!.length, ), alignment: Alignment.center, ), @@ -102,11 +102,11 @@ class CarouselState extends State { } class Indicator extends StatefulWidget { - Indicator({Key key, int count}) + Indicator({Key? key, int? count}) : count = count, super(key: key); - final int count; + final int? count; @override createState() => new IndicatorState(); @@ -124,7 +124,7 @@ class IndicatorState extends State { @override Widget build(BuildContext context) { var indicators = []; - for (var i = 0; i < widget.count; ++i) { + for (var i = 0; i < widget.count!; ++i) { indicators.add(new Container( width: 5.0, height: 5.0, @@ -135,7 +135,7 @@ class IndicatorState extends State { )); } return new SizedBox( - width: widget.count * 15.0, + width: widget.count! * 15.0, height: 30.0, child: new Row( children: indicators, diff --git a/lib/widgets/general/double_back_to_close_app_wrapper.dart b/lib/widgets/general/double_back_to_close_app_wrapper.dart index 8d66405..ba9be28 100644 --- a/lib/widgets/general/double_back_to_close_app_wrapper.dart +++ b/lib/widgets/general/double_back_to_close_app_wrapper.dart @@ -4,9 +4,9 @@ import '../../generated/l10n.dart'; import '../../utils/double_back_to_close_app.dart'; class DoubleBackToCloseAppWrapper extends StatelessWidget { - final Widget child; + final Widget? child; - const DoubleBackToCloseAppWrapper({Key key, this.child}) : super(key: key); + const DoubleBackToCloseAppWrapper({Key? key, this.child}) : super(key: key); @override Widget build(BuildContext context) { @@ -20,7 +20,7 @@ class DoubleBackToCloseAppWrapper extends StatelessWidget { ), ), ), - child: child, + child: child!, ); } } \ No newline at end of file diff --git a/lib/widgets/general/download_item.dart b/lib/widgets/general/download_item.dart index dcf6d49..eceea23 100644 --- a/lib/widgets/general/download_item.dart +++ b/lib/widgets/general/download_item.dart @@ -12,8 +12,8 @@ import '../../utils/utils.dart'; class DownloadItem extends StatefulWidget { final dynamic desc; - final double width; - const DownloadItem(this.desc, {Key key, this.width}) : super(key: key); + final double? width; + const DownloadItem(this.desc, {Key? key, this.width}) : super(key: key); @override State createState() { @@ -52,7 +52,7 @@ class DownloadItemState extends State { margin: EdgeInsets.only(right: 16.0), ), Container( - width: widget.width != null ? widget.width - iconWidth - buttonWidth - 60 : MediaQuery.of(context).size.width - iconWidth - buttonWidth - 60, + width: widget.width != null ? widget.width! - iconWidth - buttonWidth - 60 : MediaQuery.of(context).size.width - iconWidth - buttonWidth - 60, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -186,9 +186,9 @@ class DownloadItemState extends State { } Widget getDownloadButton() { - String downloadUrl; - String os = Utils.getOs(); - String selectedOs; + String? downloadUrl; + String? os = Utils.getOs(); + String? selectedOs; List supportedOss = []; for (int i = 0; i < (widget.desc['urls'] as List).length; i++) { supportedOss.add((widget.desc['urls'] as List)[i]['os']); @@ -244,7 +244,7 @@ class DownloadItemState extends State { } else if (downloadUrl != null && downloadUrl.isNotEmpty) { return ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, padding: EdgeInsets.all(8) ), child: Row( @@ -255,7 +255,7 @@ class DownloadItemState extends State { padding: EdgeInsets.only(right: 0.0, left: 6.0, top: 6.0, bottom: 6.0), child: Icon( IconData( - Utils.getOsFontHex(selectedOs), + Utils.getOsFontHex(selectedOs!), fontFamily: 'wisetronic', fontPackage: null ), diff --git a/lib/widgets/general/index_carousel.dart b/lib/widgets/general/index_carousel.dart index 7d40ea8..48cc5a3 100644 --- a/lib/widgets/general/index_carousel.dart +++ b/lib/widgets/general/index_carousel.dart @@ -7,14 +7,14 @@ import 'package:responsive_builder/responsive_builder.dart'; class IndexCarousel extends StatelessWidget { final List galleries; - const IndexCarousel(this.galleries, {Key key}) : super(key: key); + const IndexCarousel(this.galleries, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return ScreenTypeLayout( - mobile: MobileIndexCarousel(galleries), - tablet: DesktopIndexCarousel(galleries), - desktop: DesktopIndexCarousel(galleries), + return ScreenTypeLayout.builder( + mobile: (context) => MobileIndexCarousel(galleries), + tablet: (context) => DesktopIndexCarousel(galleries), + desktop: (context) => DesktopIndexCarousel(galleries), ); } diff --git a/lib/widgets/general/index_main_content_1.dart b/lib/widgets/general/index_main_content_1.dart index e9d0ff9..cac6b40 100644 --- a/lib/widgets/general/index_main_content_1.dart +++ b/lib/widgets/general/index_main_content_1.dart @@ -6,14 +6,14 @@ import 'package:responsive_builder/responsive_builder.dart'; class IndexMainContent1 extends StatelessWidget { final String message; - const IndexMainContent1(this.message, {Key key}) : super(key: key); + const IndexMainContent1(this.message, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return ScreenTypeLayout( - mobile: MobileIndexMainContent1(message), - tablet: DesktopIndexMainContent1(message), - desktop: DesktopIndexMainContent1(message), + return ScreenTypeLayout.builder( + mobile: (context) => MobileIndexMainContent1(message), + tablet: (context) => DesktopIndexMainContent1(message), + desktop: (context) => DesktopIndexMainContent1(message), ); } diff --git a/lib/widgets/general/index_main_content_2.dart b/lib/widgets/general/index_main_content_2.dart index 842ed4c..deeca90 100644 --- a/lib/widgets/general/index_main_content_2.dart +++ b/lib/widgets/general/index_main_content_2.dart @@ -6,14 +6,14 @@ import 'package:responsive_builder/responsive_builder.dart'; class IndexMainContent2 extends StatelessWidget { final Map content; - const IndexMainContent2(this.content, {Key key}) : super(key: key); + const IndexMainContent2(this.content, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return ScreenTypeLayout( - mobile: MobileIndexMainContent2(content), - tablet: DesktopIndexMainContent2(content), - desktop: DesktopIndexMainContent2(content), + return ScreenTypeLayout.builder( + mobile: (context) => MobileIndexMainContent2(content), + tablet: (context) => DesktopIndexMainContent2(content), + desktop: (context) => DesktopIndexMainContent2(content), ); } diff --git a/lib/widgets/general/index_main_content_3.dart b/lib/widgets/general/index_main_content_3.dart index 41906ab..fef111d 100644 --- a/lib/widgets/general/index_main_content_3.dart +++ b/lib/widgets/general/index_main_content_3.dart @@ -6,14 +6,14 @@ import 'package:responsive_builder/responsive_builder.dart'; class IndexMainContent3 extends StatelessWidget { final Map content; - const IndexMainContent3(this.content, {Key key}) : super(key: key); + const IndexMainContent3(this.content, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return ScreenTypeLayout( - mobile: MobileIndexMainContent3(content), - tablet: DesktopIndexMainContent3(content), - desktop: DesktopIndexMainContent3(content), + return ScreenTypeLayout.builder( + mobile: (context) => MobileIndexMainContent3(content), + tablet: (context) => DesktopIndexMainContent3(content), + desktop: (context) => DesktopIndexMainContent3(content), ); } diff --git a/lib/widgets/general/navigationbar.dart b/lib/widgets/general/navigationbar.dart index 7504fc9..4dd5611 100644 --- a/lib/widgets/general/navigationbar.dart +++ b/lib/widgets/general/navigationbar.dart @@ -9,17 +9,17 @@ import 'breadcrumbs.dart'; typedef OnBackPress(); class MiniNavigationBar extends StatefulWidget implements PreferredSizeWidget { - final Key key; + final Key? key; final String title; final bool back; final bool toHome; final bool showMe; - final List breadCrumbs; - final double breadCrumbHeight; - final Widget shoppingCart; + final List? breadCrumbs; + final double? breadCrumbHeight; + final Widget? shoppingCart; - MiniNavigationBar({Key key, PreferredSizeWidget bottom, String title, - bool back, bool toHome, bool showMe, this.breadCrumbs, + MiniNavigationBar({Key? key, PreferredSizeWidget? bottom, String? title, + bool? back, bool? toHome, bool? showMe, this.breadCrumbs, this.breadCrumbHeight, this.shoppingCart}) : key = key, preferredSize = breadCrumbHeight != null ? Size.fromHeight(kToolbarHeight + breadCrumbHeight) : @@ -43,12 +43,12 @@ class MiniNavigationBarState extends State { @override Widget build(BuildContext context) { - return ScreenTypeLayout( - mobile: MobileNavigationBar(title: widget.title, back: widget.back, + return ScreenTypeLayout.builder( + mobile: (context) => MobileNavigationBar(title: widget.title, back: widget.back, toHome: widget.toHome, showMe: widget.showMe,), - tablet: DesktopNavigationBar(hasBack: widget.back, + tablet: (context) => DesktopNavigationBar(hasBack: widget.back, breadCrumbs: widget.breadCrumbs, shoppingCart: widget.shoppingCart,), - desktop: DesktopNavigationBar(hasBack: widget.back, + desktop: (context) => DesktopNavigationBar(hasBack: widget.back, breadCrumbs: widget.breadCrumbs, shoppingCart: widget.shoppingCart,), ); } diff --git a/lib/widgets/general/navigationbar_logo.dart b/lib/widgets/general/navigationbar_logo.dart index 2d674b3..aeb2653 100644 --- a/lib/widgets/general/navigationbar_logo.dart +++ b/lib/widgets/general/navigationbar_logo.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import '../../constants.dart'; class NavigationBarLogo extends StatelessWidget { - const NavigationBarLogo({Key key}) : super(key: key); + const NavigationBarLogo({Key? key}) : super(key: key); static const IconData logoData = IconData( Constants.FONT_WISETRONIC, diff --git a/lib/widgets/general/parabolic_animation_widget.dart b/lib/widgets/general/parabolic_animation_widget.dart index 5aa0176..ac0b192 100644 --- a/lib/widgets/general/parabolic_animation_widget.dart +++ b/lib/widgets/general/parabolic_animation_widget.dart @@ -6,30 +6,30 @@ class ParabolicAnimationWidget extends AnimatedWidget { final GlobalKey stackKey; final GlobalKey startKey; final GlobalKey endKey; - final double size; - final Color color; - final Offset startAdjustOffset; - final Offset endAdjustOffset; + final double? size; + final Color? color; + final Offset? startAdjustOffset; + final Offset? endAdjustOffset; ParabolicAnimationWidget({ - @required Animation animation, - @required this.stackKey, - @required this.startKey, - @required this.endKey, + required Animation animation, + required this.stackKey, + required this.startKey, + required this.endKey, this.size = 20.0, this.color = Colors.red, this.startAdjustOffset = Offset.zero, this.endAdjustOffset = Offset.zero, }) : super(listenable: animation); - Offset _startOffset; - Offset _endOffset; + Offset _startOffset = Offset.zero; + Offset _endOffset = Offset.zero; @override Widget build(BuildContext context) { _calPoints(); - final Animation animation = listenable; + final Animation animation = listenable as Animation; final double time = animation.value; // 设time=1 已知两点坐标 和 初速度 可求出 加速度 a @@ -58,7 +58,7 @@ class ParabolicAnimationWidget extends AnimatedWidget { width: size, decoration: BoxDecoration( color: color, - borderRadius: BorderRadius.all(Radius.circular(size / 2.0))), + borderRadius: BorderRadius.all(Radius.circular(size! / 2.0))), ), ), ); @@ -66,26 +66,26 @@ class ParabolicAnimationWidget extends AnimatedWidget { void _calPoints() { if (_startOffset == null) { - RenderBox stackBox = stackKey.currentContext.findRenderObject(); + RenderBox stackBox = stackKey.currentContext?.findRenderObject() as RenderBox; Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero); EdgeInsets startMargin = _margin(startKey); - RenderBox startBox = startKey.currentContext.findRenderObject(); + RenderBox startBox = startKey.currentContext?.findRenderObject() as RenderBox; _startOffset = startBox.localToGlobal(Offset( - startMargin.left + startAdjustOffset.dx, - stackBoxOffset.dy + startMargin.top + startAdjustOffset.dy)); + startMargin.left + startAdjustOffset!.dx, + stackBoxOffset.dy + startMargin.top + startAdjustOffset!.dy)); EdgeInsets endMargin = _margin(endKey); - RenderBox endBox = endKey.currentContext.findRenderObject(); + RenderBox endBox = endKey.currentContext?.findRenderObject() as RenderBox; _endOffset = endBox.localToGlobal(Offset( - endMargin.left + endAdjustOffset.dx, - stackBoxOffset.dy + endMargin.top + endAdjustOffset.dy)); + endMargin.left + endAdjustOffset!.dx, + stackBoxOffset.dy + endMargin.top + endAdjustOffset!.dy)); } } EdgeInsets _margin(GlobalKey key) { - final Widget widget = key.currentContext.widget; - EdgeInsets margin = (widget is Container) ? widget.margin : EdgeInsets.zero; + final Widget widget = key.currentContext!.widget; + EdgeInsets margin = (widget is Container) ? widget.margin as EdgeInsets : EdgeInsets.zero; return margin ?? EdgeInsets.zero; } } \ No newline at end of file diff --git a/lib/widgets/general/payment_verification_code_dialog.dart b/lib/widgets/general/payment_verification_code_dialog.dart index 0321372..f44751b 100644 --- a/lib/widgets/general/payment_verification_code_dialog.dart +++ b/lib/widgets/general/payment_verification_code_dialog.dart @@ -1,5 +1,3 @@ - -import 'package:countdown/countdown.dart'; import 'package:flutter/material.dart'; import 'package:pinput/pin_put/pin_put.dart'; @@ -7,17 +5,17 @@ import '../../generated/l10n.dart'; import '../../models/user.dart'; import '../../utils/http_util.dart'; import '../../utils/utils.dart'; +import '../../vendor/countdown/src/countdown_base.dart'; typedef OnCodeVerified(); typedef OnCancel(); class PaymentVerificationCodeDialog extends StatefulWidget { - final Key key; final User user; final OnCodeVerified onCodeVerified; final OnCancel onCancel; - const PaymentVerificationCodeDialog(this.user, this.onCodeVerified, this.onCancel, {this.key}); + const PaymentVerificationCodeDialog(this.user, this.onCodeVerified, this.onCancel, {Key? key}) : super(key: key); @override State createState() { @@ -33,8 +31,8 @@ class PaymentVerificationCodeDialogState extends State animation; PopupAnimationWidget({ - @required this.animation, - @required this.stackKey, - @required this.startKey, - @required this.child, + required this.animation, + required this.stackKey, + required this.startKey, + required this.child, this.color = Colors.yellow, this.popupOffset = Offset.zero, }) : super(listenable: animation); - Offset _startOffset; + Offset _startOffset = Offset.zero; Offset _offset = Offset.zero; @override @@ -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() as RenderBox; final Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero); final EdgeInsets startMargin = _margin(startKey); - final RenderBox startBox = startKey.currentContext.findRenderObject(); + final RenderBox startBox = startKey.currentContext?.findRenderObject() as RenderBox; _startOffset = startBox.localToGlobal(Offset( startMargin.left + popupOffset.dx, @@ -62,9 +62,9 @@ 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; + (widget is Container) ? widget.margin as EdgeInsets : EdgeInsets.zero; return margin ?? EdgeInsets.zero; } } \ No newline at end of file diff --git a/lib/widgets/general/read_more_text.dart b/lib/widgets/general/read_more_text.dart index 8d5227f..ec82b7d 100644 --- a/lib/widgets/general/read_more_text.dart +++ b/lib/widgets/general/read_more_text.dart @@ -9,7 +9,7 @@ enum TrimMode { class ReadMoreText extends StatefulWidget { const ReadMoreText( this.data, { - Key key, + Key? key, this.trimExpandedText = ' read less', this.trimCollapsedText = ' ...read more', this.colorClickableText, @@ -28,16 +28,16 @@ class ReadMoreText extends StatefulWidget { final String data; final String trimExpandedText; final String trimCollapsedText; - final Color colorClickableText; + final Color? colorClickableText; final int trimLength; final int trimLines; final TrimMode trimMode; - final TextStyle style; - final TextAlign textAlign; - final TextDirection textDirection; - final Locale locale; - final double textScaleFactor; - final String semanticsLabel; + final TextStyle? style; + final TextAlign? textAlign; + final TextDirection? textDirection; + final Locale? locale; + final double? textScaleFactor; + final String? semanticsLabel; @override ReadMoreTextState createState() => ReadMoreTextState(); @@ -57,8 +57,8 @@ class ReadMoreTextState extends State { @override Widget build(BuildContext context) { final DefaultTextStyle defaultTextStyle = DefaultTextStyle.of(context); - TextStyle effectiveTextStyle = widget.style; - if (widget.style == null || widget.style.inherit) { + TextStyle? effectiveTextStyle = widget.style; + if (widget.style == null || widget.style!.inherit) { effectiveTextStyle = defaultTextStyle.style.merge(widget.style); } @@ -66,7 +66,7 @@ class ReadMoreTextState extends State { widget.textAlign ?? defaultTextStyle.textAlign ?? TextAlign.start; final textDirection = widget.textDirection ?? Directionality.of(context); final textScaleFactor = - widget.textScaleFactor ?? MediaQuery.textScaleFactorOf(context); + widget.textScaleFactor ?? MediaQuery.textScalerOf(context).scale(1); final overflow = defaultTextStyle.overflow; final locale = widget.locale ?? Localizations.localeOf(context); @@ -76,7 +76,7 @@ class ReadMoreTextState extends State { TextSpan link = TextSpan( text: _readMore ? widget.trimCollapsedText : widget.trimExpandedText, - style: effectiveTextStyle.copyWith( + style: effectiveTextStyle?.copyWith( color: colorClickableText, ), recognizer: TapGestureRecognizer()..onTap = _onTapLink, @@ -98,7 +98,7 @@ class ReadMoreTextState extends State { text: link, textAlign: textAlign, textDirection: textDirection, - textScaleFactor: textScaleFactor, + textScaler: TextScaler.linear(textScaleFactor), maxLines: widget.trimLines, ellipsis: overflow == TextOverflow.ellipsis ? _kEllipsis : null, locale: locale, @@ -115,7 +115,7 @@ class ReadMoreTextState extends State { // Get the endIndex of data bool linkLongerThanLine = false; - int endIndex; + int? endIndex; if (linkSize.width < maxWidth) { final pos = textPainter.getPositionForOffset(Offset( diff --git a/lib/widgets/general/show_price.dart b/lib/widgets/general/show_price.dart index 3183639..7778780 100644 --- a/lib/widgets/general/show_price.dart +++ b/lib/widgets/general/show_price.dart @@ -3,10 +3,10 @@ import 'package:flutter/material.dart'; class ShowPrice extends StatelessWidget { final double price; - final double regularPrice; + final double? regularPrice; final double largeFontSize; final double smallFontSize; - final String currencySign; + final String? currencySign; final Color color; final FontWeight fontWeight; @@ -36,7 +36,7 @@ class ShowPrice extends StatelessWidget { Container( padding: EdgeInsets.only(top: largeFontSize / 10.0), child: Text( - currencySign, + currencySign!, style: TextStyle( fontSize: smallFontSize, color: color, @@ -65,12 +65,12 @@ class ShowPrice extends StatelessWidget { ), ), ), - regularPrice == null || price.round() >= regularPrice.round() ? + regularPrice == null || price.round() >= regularPrice!.round() ? SizedBox.shrink() : Container( padding: EdgeInsets.only(top: largeFontSize / 2), child: Text( - regularPrice.toStringAsFixed(0), + '${regularPrice?.toStringAsFixed(0)}', style: TextStyle( color: Colors.black38, fontSize: smallFontSize, diff --git a/lib/widgets/general/sliding_up_panel.dart b/lib/widgets/general/sliding_up_panel.dart index 732cee8..959e076 100644 --- a/lib/widgets/general/sliding_up_panel.dart +++ b/lib/widgets/general/sliding_up_panel.dart @@ -30,7 +30,7 @@ class SlidingUpPanel extends StatefulWidget { /// otherwise, [collapsed] will be displayed overtop /// of this Widget. If [panel] and [panelBuilder] are both non-null, /// [panel] will be used. - final Widget panel; + final Widget? panel; /// WARNING: This feature is still in beta and is subject to change without /// notice. Stability is not gauranteed. Provides a [ScrollController] and @@ -38,28 +38,28 @@ class SlidingUpPanel extends StatefulWidget { /// the panel position with the scroll position. Useful for implementing an /// infinite scroll behavior. If [panel] and [panelBuilder] are both non-null, /// [panel] will be used. - final Widget Function(ScrollController sc) panelBuilder; + final Widget? Function(ScrollController sc)? panelBuilder; /// The Widget displayed overtop the [panel] when collapsed. /// This fades out as the panel is opened. - final Widget collapsed; + final Widget? collapsed; /// The Widget that lies underneath the sliding panel. /// This Widget automatically sizes itself /// to fill the screen. - final Widget body; + final Widget? body; /// Optional persistent widget that floats above the [panel] and attaches /// to the top of the [panel]. Content at the top of the panel will be covered /// by this widget. Add padding to the bottom of the `panel` to /// avoid coverage. - final Widget header; + final Widget? header; /// Optional persistent widget that floats above the [panel] and /// attaches to the bottom of the [panel]. Content at the bottom of the panel /// will be covered by this widget. Add padding to the bottom of the `panel` /// to avoid coverage. - final Widget footer; + final Widget? footer; /// The height of the sliding panel when fully collapsed. final double minHeight; @@ -72,13 +72,13 @@ class SlidingUpPanel extends StatefulWidget { /// and go directly to the open/close position. This value is represented as a /// percentage of the total animation distance ([maxHeight] - [minHeight]), /// so it must be between 0.0 and 1.0, exclusive. - final double snapPoint; + final double? snapPoint; /// A border to draw around the sliding panel sheet. - final Border border; + final Border? border; /// If non-null, the corners of the sliding panel sheet are rounded by this [BorderRadiusGeometry]. - final BorderRadiusGeometry borderRadius; + final BorderRadiusGeometry? borderRadius; /// A list of shadows cast behind the sliding panel sheet. final List boxShadow; @@ -87,10 +87,10 @@ class SlidingUpPanel extends StatefulWidget { final Color color; /// The amount to inset the children of the sliding panel sheet. - final EdgeInsetsGeometry padding; + final EdgeInsetsGeometry? padding; /// Empty space surrounding the sliding panel sheet. - final EdgeInsetsGeometry margin; + final EdgeInsetsGeometry? margin; /// Set to false to not to render the sheet the [panel] sits upon. /// This means that only the [body], [collapsed], and the [panel] @@ -104,7 +104,7 @@ class SlidingUpPanel extends StatefulWidget { final bool panelSnapping; /// If non-null, this can be used to control the state of the panel. - final PanelController controller; + final PanelController? controller; /// If non-null, shows a darkening shadow over the [body] as the panel slides open. final bool backdropEnabled; @@ -125,15 +125,15 @@ class SlidingUpPanel extends StatefulWidget { /// is called as the panel slides around with the /// current position of the panel. The position is a double /// between 0.0 and 1.0 where 0.0 is fully collapsed and 1.0 is fully open. - final void Function(double position) onPanelSlide; + final void Function(double position)? onPanelSlide; /// If non-null, this callback is called when the /// panel is fully opened - final VoidCallback onPanelOpened; + final VoidCallback? onPanelOpened; /// If non-null, this callback is called when the panel /// is fully collapsed. - final VoidCallback onPanelClosed; + final VoidCallback? onPanelClosed; /// If non-null and true, the SlidingUpPanel exhibits a /// parallax effect as the panel slides up. Essentially, @@ -164,7 +164,7 @@ class SlidingUpPanel extends StatefulWidget { final PanelState defaultPanelState; SlidingUpPanel({ - Key key, + Key? key, this.panel, this.panelBuilder, this.body, @@ -211,9 +211,9 @@ class SlidingUpPanel extends StatefulWidget { class _SlidingUpPanelState extends State with SingleTickerProviderStateMixin{ - AnimationController _ac; + AnimationController? _ac; - ScrollController _sc; + ScrollController? _sc; bool _scrollingEnabled = false; VelocityTracker _vt = VelocityTracker.withKind(PointerDeviceKind.touch); @@ -228,19 +228,19 @@ class _SlidingUpPanelState extends State with SingleTickerProvid duration: const Duration(milliseconds: 300), value: widget.defaultPanelState == PanelState.CLOSED ? 0.0 : 1.0 //set the default panel state (i.e. set initial value of _ac) )..addListener((){ - if(widget.onPanelSlide != null) widget.onPanelSlide(_ac.value); + if(widget.onPanelSlide != null) widget.onPanelSlide!(_ac!.value); - if(widget.onPanelOpened != null && _ac.value == 1.0) widget.onPanelOpened(); + if(widget.onPanelOpened != null && _ac!.value == 1.0) widget.onPanelOpened!(); - if(widget.onPanelClosed != null && _ac.value == 0.0) widget.onPanelClosed(); + if(widget.onPanelClosed != null && _ac!.value == 0.0) widget.onPanelClosed!(); }); // prevent the panel content from being scrolled only if the widget is // draggable and panel scrolling is enabled _sc = new ScrollController(); - _sc.addListener((){ - if(widget.isDraggable && !_scrollingEnabled) - _sc.jumpTo(0); + _sc!.addListener((){ + if(widget.isDraggable! && !_scrollingEnabled) + _sc!.jumpTo(0); }); widget.controller?._addState(this); @@ -254,11 +254,11 @@ class _SlidingUpPanelState extends State with SingleTickerProvid //make the back widget take up the entire back side widget.body != null ? AnimatedBuilder( - animation: _ac, + animation: _ac!, builder: (context, child){ return Positioned( - top: widget.parallaxEnabled ? _getParallax() : 0.0, - child: child, + top: widget.parallaxEnabled! ? _getParallax() : 0.0, + child: child!, ); }, child: Container( @@ -278,7 +278,7 @@ class _SlidingUpPanelState extends State with SingleTickerProvid } : null, onTap: widget.backdropTapClosesPanel ? () => _close() : null, child: AnimatedBuilder( - animation: _ac, + animation: _ac!, builder: (context, _) { return Container( height: MediaQuery.of(context).size.height, @@ -287,7 +287,7 @@ class _SlidingUpPanelState extends State with SingleTickerProvid //set color to null so that touch events pass through //to the body when the panel is closed, otherwise, //if a color exists, then touch events won't go through - color: _ac.value == 0.0 ? null : widget.backdropColor.withOpacity(widget.backdropOpacity * _ac.value), + color: _ac!.value == 0.0 ? null : widget.backdropColor.withOpacity(widget.backdropOpacity * _ac!.value), ); } ), @@ -296,10 +296,10 @@ class _SlidingUpPanelState extends State with SingleTickerProvid //the actual sliding part !_isPanelVisible ? Container() : _gestureHandler( child: AnimatedBuilder( - animation: _ac, + animation: _ac!, builder: (context, child) { return Container( - height: _ac.value * (widget.maxHeight - widget.minHeight) + widget.minHeight, + height: _ac!.value * (widget.maxHeight - widget.minHeight) + widget.minHeight, margin: widget.margin, padding: widget.padding, decoration: widget.renderPanelSheet ? BoxDecoration( @@ -320,13 +320,13 @@ class _SlidingUpPanelState extends State with SingleTickerProvid top: widget.slideDirection == SlideDirection.UP ? 0.0 : null, bottom: widget.slideDirection == SlideDirection.DOWN ? 0.0 : null, width: MediaQuery.of(context).size.width - - (widget.margin != null ? widget.margin.horizontal : 0) - - (widget.padding != null ? widget.padding.horizontal : 0), + (widget.margin != null ? widget.margin!.horizontal : 0) - + (widget.padding != null ? widget.padding!.horizontal : 0), child: Container( height: widget.maxHeight, child: widget.panel != null ? widget.panel - : widget.panelBuilder(_sc), + : widget.panelBuilder!(_sc!), ), ), @@ -334,14 +334,14 @@ class _SlidingUpPanelState extends State with SingleTickerProvid widget.header != null ? Positioned( top: widget.slideDirection == SlideDirection.UP ? 0.0 : null, bottom: widget.slideDirection == SlideDirection.DOWN ? 0.0 : null, - child: widget.header, + child: widget.header!, ) : Container(), // footer widget.footer != null ? Positioned( top: widget.slideDirection == SlideDirection.UP ? null : 0.0, bottom: widget.slideDirection == SlideDirection.DOWN ? null : 0.0, - child: widget.footer + child: widget.footer! ) : Container(), // collapsed panel @@ -349,12 +349,12 @@ class _SlidingUpPanelState extends State with SingleTickerProvid top: widget.slideDirection == SlideDirection.UP ? 0.0 : null, bottom: widget.slideDirection == SlideDirection.DOWN ? 0.0 : null, width: MediaQuery.of(context).size.width - - (widget.margin != null ? widget.margin.horizontal : 0) - - (widget.padding != null ? widget.padding.horizontal : 0), + (widget.margin != null ? widget.margin!.horizontal : 0) - + (widget.padding != null ? widget.padding!.horizontal : 0), child: Container( height: widget.minHeight, child: widget.collapsed == null ? Container() : FadeTransition( - opacity: Tween(begin: 1.0, end: 0.0).animate(_ac), + opacity: Tween(begin: 1.0, end: 0.0).animate(_ac!), // if the panel is open ignore pointers (touch events) on the collapsed // child so that way touch events go through to whatever is underneath @@ -375,22 +375,22 @@ class _SlidingUpPanelState extends State with SingleTickerProvid @override void dispose(){ - _ac.dispose(); + _ac?.dispose(); super.dispose(); } double _getParallax(){ if(widget.slideDirection == SlideDirection.UP) - return -_ac.value * (widget.maxHeight - widget.minHeight) * widget.parallaxOffset; + return -_ac!.value * (widget.maxHeight - widget.minHeight) * widget.parallaxOffset; else - return _ac.value * (widget.maxHeight - widget.minHeight) * widget.parallaxOffset; + return _ac!.value * (widget.maxHeight - widget.minHeight) * widget.parallaxOffset; } // returns a gesture detector if panel is used // 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({required Widget child}){ if (!widget.isDraggable) return child; if (widget.panel != null){ @@ -418,15 +418,15 @@ class _SlidingUpPanelState extends State with SingleTickerProvid // only slide the panel if scrolling is not enabled if(!_scrollingEnabled){ if(widget.slideDirection == SlideDirection.UP) - _ac.value -= dy / (widget.maxHeight - widget.minHeight); + _ac!.value -= dy / (widget.maxHeight - widget.minHeight); else - _ac.value += dy / (widget.maxHeight - widget.minHeight); + _ac!.value += dy / (widget.maxHeight - widget.minHeight); } // if the panel is open and the user hasn't scrolled, we need to determine // whether to enable scrolling if the user swipes up, or disable closing and // begin to close the panel if the user swipes down - if(_isPanelOpen && _sc.hasClients && _sc.offset <= 0){ + if(_isPanelOpen && _sc!.hasClients && _sc!.offset <= 0){ setState(() { if(dy < 0){ _scrollingEnabled = true; @@ -443,7 +443,7 @@ class _SlidingUpPanelState extends State with SingleTickerProvid double kSnap = 8; //let the current animation finish before starting a new one - if(_ac.isAnimating) return; + if(_ac!.isAnimating) return; // if scrolling is allowed and the panel is open, we don't want to close // the panel if they swipe up on the scrollable @@ -458,9 +458,9 @@ class _SlidingUpPanelState extends State with SingleTickerProvid // get minimum distances to figure out where the panel is at - double d2Close = _ac.value; - double d2Open = 1 - _ac.value; - double d2Snap = ((widget.snapPoint ?? 3) -_ac.value).abs(); // large value if null results in not every being the min + double d2Close = _ac!.value; + double d2Open = 1 - _ac!.value; + double d2Snap = ((widget.snapPoint ?? 3) -_ac!.value).abs(); // large value if null results in not every being the min double minDistance = min(d2Close, min(d2Snap, d2Open)); // check if velocity is sufficient for a fling @@ -469,18 +469,18 @@ class _SlidingUpPanelState extends State with SingleTickerProvid // snapPoint exists if(widget.panelSnapping && widget.snapPoint != null){ if(v.pixelsPerSecond.dy.abs() >= kSnap*minFlingVelocity || minDistance == d2Snap) - _ac.fling(velocity: visualVelocity); + _ac!.fling(velocity: visualVelocity); else - _flingPanelToPosition(widget.snapPoint, visualVelocity); + _flingPanelToPosition(widget.snapPoint!, visualVelocity); // no snap point exists }else if(widget.panelSnapping){ - _ac.fling(velocity: visualVelocity); + _ac!.fling(velocity: visualVelocity); // panel snapping disabled }else{ - _ac.animateTo( - _ac.value + visualVelocity * 0.16, + _ac!.animateTo( + _ac!.value + visualVelocity * 0.16, duration: Duration(milliseconds: 410), curve: Curves.decelerate, ); @@ -495,7 +495,7 @@ class _SlidingUpPanelState extends State with SingleTickerProvid if(minDistance == d2Close){ _close(); }else if(minDistance == d2Snap){ - _flingPanelToPosition(widget.snapPoint, visualVelocity); + _flingPanelToPosition(widget.snapPoint!, visualVelocity); }else{ _open(); } @@ -510,12 +510,12 @@ class _SlidingUpPanelState extends State with SingleTickerProvid stiffness: 500.0, ratio: 1.0, ), - _ac.value, + _ac!.value, targetPos, velocity ); - _ac.animateWith(simulation); + _ac!.animateWith(simulation); } //--------------------------------- @@ -524,17 +524,17 @@ class _SlidingUpPanelState extends State with SingleTickerProvid //close the panel Future _close(){ - return _ac.fling(velocity: -1.0); + return _ac!.fling(velocity: -1.0); } //open the panel Future _open(){ - return _ac.fling(velocity: 1.0); + return _ac!.fling(velocity: 1.0); } //hide the panel (completely offscreen) Future _hide(){ - return _ac.fling(velocity: -1.0).then((x){ + return _ac!.fling(velocity: -1.0).then((x){ setState(() { _isPanelVisible = false; }); @@ -543,7 +543,7 @@ class _SlidingUpPanelState extends State with SingleTickerProvid //show the panel (in collapsed mode) Future _show(){ - return _ac.fling(velocity: -1.0).then((x){ + return _ac!.fling(velocity: -1.0).then((x){ setState(() { _isPanelVisible = true; }); @@ -552,41 +552,41 @@ 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, {required Duration duration, Curve curve = Curves.linear}){ assert(0.0 <= value && value <= 1.0); - return _ac.animateTo(value, duration: duration, curve: curve); + 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({required Duration duration, Curve curve = Curves.linear}){ assert(widget.snapPoint != null); - return _ac.animateTo(widget.snapPoint, duration: duration, curve: curve); + return _ac!.animateTo(widget.snapPoint!, duration: duration, curve: curve); } //set the panel position to value - must //be between 0.0 and 1.0 set _panelPosition(double value){ assert(0.0 <= value && value <= 1.0); - _ac.value = value; + _ac!.value = value; } //get the current panel position //returns the % offset from collapsed state //as a decimal between 0.0 and 1.0 - double get _panelPosition => _ac.value; + double get _panelPosition => _ac!.value; //returns whether or not //the panel is still animating - bool get _isPanelAnimating => _ac.isAnimating; + bool get _isPanelAnimating => _ac!.isAnimating; //returns whether or not the //panel is open - bool get _isPanelOpen => _ac.value == 1.0; + bool get _isPanelOpen => _ac!.value == 1.0; //returns whether or not the //panel is closed - bool get _isPanelClosed => _ac.value == 0.0; + bool get _isPanelClosed => _ac!.value == 0.0; //returns whether or not the //panel is shown/hidden @@ -602,7 +602,7 @@ class _SlidingUpPanelState extends State with SingleTickerProvid class PanelController{ - _SlidingUpPanelState _panelState; + _SlidingUpPanelState? _panelState; void _addState(_SlidingUpPanelState panelState){ this._panelState = panelState; @@ -616,27 +616,27 @@ class PanelController{ /// Closes the sliding panel to its collapsed state (i.e. to the minHeight) Future close(){ assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); - return _panelState._close(); + return _panelState!._close(); } /// Opens the sliding panel fully /// (i.e. to the maxHeight) Future open(){ assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); - return _panelState._open(); + return _panelState!._open(); } /// Hides the sliding panel (i.e. is invisible) Future hide(){ assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); - return _panelState._hide(); + return _panelState!._hide(); } /// Shows the sliding panel in its collapsed state /// (i.e. "un-hide" the sliding panel) Future show(){ assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); - return _panelState._show(); + return _panelState!._show(); } /// Animates the panel position to the value. @@ -644,20 +644,20 @@ 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, {required 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); + return _panelState!._animatePanelToPosition(value, duration: duration, curve: curve); } /// Animates the panel position to the snap point /// 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({required 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); + assert(_panelState!.widget.snapPoint != null, "SlidingUpPanel snapPoint property must not be null"); + return _panelState!._animatePanelToSnapPoint(duration: duration, curve: curve); } /// Sets the panel position (without animation). @@ -666,7 +666,7 @@ class PanelController{ set panelPosition(double value){ assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); assert(0.0 <= value && value <= 1.0); - _panelState._panelPosition = value; + _panelState!._panelPosition = value; } /// Gets the current panel position. @@ -677,35 +677,35 @@ class PanelController{ /// 1.0 is full open. double get panelPosition{ assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); - return _panelState._panelPosition; + return _panelState!._panelPosition; } /// Returns whether or not the panel is /// currently animating. bool get isPanelAnimating{ assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); - return _panelState._isPanelAnimating; + return _panelState!._isPanelAnimating; } /// Returns whether or not the /// panel is open. bool get isPanelOpen{ assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); - return _panelState._isPanelOpen; + return _panelState!._isPanelOpen; } /// Returns whether or not the /// panel is closed. bool get isPanelClosed{ assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); - return _panelState._isPanelClosed; + return _panelState!._isPanelClosed; } /// Returns whether or not the /// panel is shown/hidden. bool get isPanelShown{ assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); - return _panelState._isPanelShown; + return _panelState!._isPanelShown; } } \ No newline at end of file diff --git a/lib/widgets/general/stripe_pay.dart b/lib/widgets/general/stripe_pay.dart index bbc442c..0eb9b13 100644 --- a/lib/widgets/general/stripe_pay.dart +++ b/lib/widgets/general/stripe_pay.dart @@ -16,11 +16,10 @@ import '../../utils/utils.dart'; class StripePay extends StatefulWidget { - final Key key; final Order order; final PaymentPlatform paymentPlatform; - final StripePaymentMethod stripePaymentMethod; - const StripePay(this.order, this.paymentPlatform, {this.key, this.stripePaymentMethod}); + final StripePaymentMethod? stripePaymentMethod; + const StripePay(this.order, this.paymentPlatform, {Key? key, this.stripePaymentMethod}) : super(key: key); @override State createState() { @@ -33,7 +32,7 @@ class StripePayState extends State { GlobalKey _scaffoldKey = GlobalKey(); - bool isSubmitting; + bool isSubmitting = false; @override Widget build(BuildContext context) { @@ -71,9 +70,9 @@ class StripePayState extends State { } _paymentWithPaymentMethod(BuildContext context) async { - Utils.stripePaymentIntent(widget.order, widget.stripePaymentMethod.customerId, - widget.stripePaymentMethod.paymentMethodId, - widget.stripePaymentMethod.paymentMethodType, (response){ + Utils.stripePaymentIntent(widget.order, widget.stripePaymentMethod?.customerId, + widget.stripePaymentMethod!.paymentMethodId, + widget.stripePaymentMethod!.paymentMethodType, (response){ if (response.data['status'] == Constants.STRIPE_STATUS_REQUIRES_CONFIRMATION) { StripePayment.confirmPaymentIntent( @@ -84,8 +83,8 @@ class StripePayState extends State { ).then((paymentIntentResult) { if (paymentIntentResult.status == Constants.STRIPE_STATUS_SUCCEDED) { Utils.stripeChargedSuccess(widget.order, - widget.stripePaymentMethod.paymentMethodId, - paymentIntentResult.paymentIntentId, + widget.stripePaymentMethod!.paymentMethodId, + paymentIntentResult.paymentIntentId!, (response) { eventBus.fire(OnOrderUpdated()); Routes.router.navigateTo(context, '/orderdetail/${widget @@ -107,7 +106,7 @@ class StripePayState extends State { StripePayment.paymentRequestWithCardForm( CardFormPaymentRequest() ).then((paymentMethod) { - Utils.stripePaymentIntent(widget.order, null, paymentMethod.id, paymentMethod.type, (response){ + Utils.stripePaymentIntent(widget.order, null, paymentMethod.id!, paymentMethod.type!, (response){ if (response.data['status'] == Constants.STRIPE_STATUS_REQUIRES_CONFIRMATION) { StripePayment.confirmPaymentIntent( @@ -118,8 +117,8 @@ class StripePayState extends State { ).then((paymentIntentResult) { if (paymentIntentResult.status == Constants.STRIPE_STATUS_SUCCEDED) { Utils.stripeChargedSuccess(widget.order, - paymentMethod.id, - paymentIntentResult.paymentIntentId, + paymentMethod.id!, + paymentIntentResult.paymentIntentId!, (response) { eventBus.fire(OnOrderUpdated()); Routes.router.navigateTo(context, '/orderdetail/${widget @@ -133,12 +132,12 @@ class StripePayState extends State { }).catchError(showErrorDialog); } }, (showErrorDialog), - cardBrand: paymentMethod.card.brand, - cardCountry: paymentMethod.card.country, - cardExpMonth: paymentMethod.card.expMonth, - cardExpYear: paymentMethod.card.expYear, - cardFunding: paymentMethod.card.funding, - cardLast4: paymentMethod.card.last4, + cardBrand: paymentMethod.card!.brand, + cardCountry: paymentMethod.card!.country, + cardExpMonth: paymentMethod.card!.expMonth, + cardExpYear: paymentMethod.card!.expYear, + cardFunding: paymentMethod.card!.funding, + cardLast4: paymentMethod.card!.last4, ); }).catchError(showErrorDialog); isSubmitting = true; diff --git a/lib/widgets/general/text_link.dart b/lib/widgets/general/text_link.dart index 4ebf529..4abc76d 100644 --- a/lib/widgets/general/text_link.dart +++ b/lib/widgets/general/text_link.dart @@ -10,26 +10,26 @@ import '../../routes.dart'; class TextLink extends StatelessWidget { final String title; - final String url; - final Color color; - final Color hoverColor; - final double paddingHorizontal; - final double paddingVertical; - final FontWeight fontWeight; - final bool selected; - final bool isLink; - final bool replace; - final bool clearStack; - final bool maintainState; - final bool rootNavigator; - final TransitionType transition; - final bool closeDrawer; - final bool isEmail; - final bool isPhone; - final double fontSize; - final bool isAddress; - final TextOverflow overflow; - final int maxLines; + final String? url; + final Color? color; + final Color? hoverColor; + final double? paddingHorizontal; + final double? paddingVertical; + final FontWeight? fontWeight; + final bool? selected; + final bool? isLink; + final bool? replace; + final bool? clearStack; + final bool? maintainState; + final bool? rootNavigator; + final TransitionType? transition; + final bool? closeDrawer; + final bool? isEmail; + final bool? isPhone; + final double? fontSize; + final bool? isAddress; + final TextOverflow? overflow; + final int? maxLines; TextLink(this.title, this.url, { this.color, @@ -38,19 +38,19 @@ class TextLink extends StatelessWidget { this.paddingVertical, this.fontWeight, this.selected, - bool isLink, - bool replace, - bool clearStack, - bool maintainState, - bool rootNavigator, + bool? isLink, + bool? replace, + bool? clearStack, + bool? maintainState, + bool? rootNavigator, this.transition, - bool closeDrawer, - bool isEmail, - bool isPhone, - double fontSize, - bool isAddress, - TextOverflow overflow, - int maxLines, + bool? closeDrawer, + bool? isEmail, + bool? isPhone, + double? fontSize, + bool? isAddress, + TextOverflow? overflow, + int? maxLines, }) : isLink = isLink ?? false, replace = replace ?? false, @@ -101,7 +101,7 @@ class TextLink extends StatelessWidget { }, ), decoration: BoxDecoration( - border: (selected != null && selected) ? Border( + border: (selected != null && selected!) ? Border( bottom: BorderSide( color: color ?? Colors.blue, width: 3.0, @@ -110,27 +110,27 @@ class TextLink extends StatelessWidget { ), ), onTap: () async { - if (selected == null || !selected) { - if (isEmail) { - Utils.openEmail(url); - } else if (isPhone) { - Utils.callPhone(url); - } else if (isAddress) { - await launch('https://maps.google.com/?q=${url}'); - } else if (!isLink) { - if (closeDrawer) { + if (selected == null || !selected!) { + if (isEmail!) { + Utils.openEmail(url!); + } else if (isPhone!) { + Utils.callPhone(url!); + } else if (isAddress!) { + await launchUrl(Uri.parse('https://maps.google.com/?q=${url}')); + } else if (!isLink!) { + if (closeDrawer!) { Routes.router.pop(context); } Routes.router.navigateTo( - context, url, - replace: replace, - clearStack: clearStack, - maintainState: maintainState, - rootNavigator: rootNavigator, + context, url!, + replace: replace!, + clearStack: clearStack!, + maintainState: maintainState!, + rootNavigator: rootNavigator!, ); } else { - if (await canLaunch(url)) { - await launch(url); + if (await canLaunchUrl(Uri.parse(url!))) { + await launchUrl(Uri.parse(url!)); } else { throw 'Could not launch $url'; } diff --git a/lib/widgets/mobile/create_online_store_1.dart b/lib/widgets/mobile/create_online_store_1.dart index 7225210..e4cc276 100644 --- a/lib/widgets/mobile/create_online_store_1.dart +++ b/lib/widgets/mobile/create_online_store_1.dart @@ -12,7 +12,7 @@ import '../../utils/utils.dart'; class CreateOnlineStore1 extends StatefulWidget { final int businessId; - const CreateOnlineStore1(this.businessId, {Key key}) : super(key: key); + const CreateOnlineStore1(this.businessId, {Key? key}) : super(key: key); @override State createState() { @@ -30,12 +30,12 @@ class CreateOnlineStore1State extends State { bool canSubmit = false; List stores = []; - Map service; + Map? service; dynamic selectedStore; - Group group; + Group? group; - String selectedDomain; + String? selectedDomain; List domainResult = []; @override @@ -136,7 +136,7 @@ class CreateOnlineStore1State extends State { ), ), ); - Map existing_web_svc; + Map? existing_web_svc; if (selectedStore != null && (selectedStore['services'] as List).length > 0) { for (Mapsvc in (selectedStore['services'] as List)) { if (svc['code'] == Constants.WEB_MINISTORE_SERVICE) { @@ -187,8 +187,8 @@ class CreateOnlineStore1State extends State { onPressed: () { Navigator.pushReplacement(context, MaterialPageRoute( builder: (BuildContext context) => - BuyService(group.id, Constants.WEB_MINISTORE_SERVICE, - domain: existing_web_svc['domain'], + BuyService(group!.id, Constants.WEB_MINISTORE_SERVICE, + domain: existing_web_svc!['domain'], sid: existing_web_svc['store']['id'], ), )); @@ -230,8 +230,8 @@ class CreateOnlineStore1State extends State { fontSize: 18.0 ), autofocus: true, - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).domains_separated_comma; } return null; @@ -269,7 +269,7 @@ class CreateOnlineStore1State extends State { Container( padding: EdgeInsets.only(top: 8.0), child: Text( - service['description'], + service!['description'], ), ), ); @@ -277,7 +277,7 @@ class CreateOnlineStore1State extends State { Container( padding: EdgeInsets.only(top: 8.0), child: Text( - service['options'][0]['name'], + service!['options'][0]['name'], ), ), ); @@ -285,7 +285,7 @@ class CreateOnlineStore1State extends State { Container( padding: EdgeInsets.only(top: 8.0), child: Text( - '\$${service['options'][0]['price']}', + '\$${service!['options'][0]['price']}', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, @@ -304,7 +304,7 @@ class CreateOnlineStore1State extends State { onPressed: () { Navigator.pushReplacement(context, MaterialPageRoute( builder: (BuildContext context) => - BuyService(group.id, Constants.WEB_MINISTORE_SERVICE, + BuyService(group!.id, Constants.WEB_MINISTORE_SERVICE, domain: selectedDomain, sid: selectedStore['id'], ), diff --git a/lib/widgets/mobile/mobile_attribute_selection.dart b/lib/widgets/mobile/mobile_attribute_selection.dart index 16e9fbb..93eb5ee 100644 --- a/lib/widgets/mobile/mobile_attribute_selection.dart +++ b/lib/widgets/mobile/mobile_attribute_selection.dart @@ -19,10 +19,9 @@ import '../../widgets/general/attribute/radio_options.dart'; class MobileAttributeSelection extends StatefulWidget { final Product product; final Business business; - final Key key; - final GlobalKey startKey; + final GlobalKey? startKey; - const MobileAttributeSelection({@required this.product, @required this.business, this.key, this.startKey}) + const MobileAttributeSelection({required this.product, required this.business, Key? key, this.startKey}) : super(key: key); @override @@ -33,18 +32,18 @@ class MobileAttributeSelection extends StatefulWidget { } class MobileAttributeSelectionState extends State { - Product product; - int index; - TextButton previousButton; - TextButton nextButton; - bool previousButtonEnable; - bool nextButtonEnable; + Product? product; + int? index; + TextButton? previousButton; + TextButton? nextButton; + bool previousButtonEnable = false; + bool nextButtonEnable = false; - String productDesc; - double productPrice; + String? productDesc; + double? productPrice; - String nextText; - String finishText; + String? nextText; + String? finishText; Map selections = new Map(); @@ -80,8 +79,8 @@ class MobileAttributeSelectionState extends State { child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - previousButton, - nextButton + previousButton!, + nextButton! ], ), ), @@ -96,8 +95,8 @@ class MobileAttributeSelectionState extends State { product = widget.product; previousButtonEnable = false; nextButtonEnable = false; - productDesc = product.description; - productPrice = product.price; + productDesc = product!.description; + productPrice = product!.price; }); eventBus.on().listen((event) { @@ -118,31 +117,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 +166,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}' ), ); @@ -180,7 +179,7 @@ class MobileAttributeSelectionState extends State { padding: new EdgeInsets.all(10.0), width: 70.0, height: 70.0, - child: Util.showImage(product.imagePath, + child: Util.showImage(product!.imagePath ?? '', width: 70.0, height: 70.0, fit: BoxFit.fill, @@ -194,7 +193,7 @@ class MobileAttributeSelectionState extends State { new Container( padding: new EdgeInsets.all(10.0).copyWith(left: 0.0).copyWith(bottom: 0.0), child: new Text( - product.name, + product!.name ?? '', style: new TextStyle( fontSize: 15.0, ), @@ -205,7 +204,7 @@ class MobileAttributeSelectionState extends State { new Container( padding: new EdgeInsets.only(right: 10.0), child: new Text( - productDesc, + productDesc ?? '', style: new TextStyle( fontSize: 9.0, color: new Color(0xFFCDCDCD) @@ -223,7 +222,7 @@ class MobileAttributeSelectionState extends State { width: 70.0, child: new Text( - productPrice.toStringAsFixed(2), + productPrice!.toStringAsFixed(2), textAlign: TextAlign.right, style: new TextStyle( fontSize: 18.0, @@ -239,14 +238,14 @@ 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); + optionsView = new QtyOptions(product: product!, index: index!, selections: selections); } else { if (productAttribute.singleSelection) { - optionsView = new RadioOptions(product: product, index: index, selections: selections); + optionsView = new RadioOptions(product: product!, index: index!, selections: selections); } else { - optionsView = new CheckOptions(product: product, index: index, selections: selections); + optionsView = new CheckOptions(product: product!, index: index!, selections: selections); } } @@ -254,27 +253,27 @@ 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; + index = index! + 1; + previousButtonEnable = index! >= 1; nextButtonEnable = _checkCanGoNext(); }); - } else if (product.productAttributes.length == index + 1) { - eventBus.fire(new OnProductWillAddToCart(product, selections, productPrice, productDesc, widget.business, buttonKey: widget.startKey)); + } else if (product!.productAttributes!.length == index! + 1) { + eventBus.fire(new OnProductWillAddToCart(product!, selections, productPrice!, productDesc ?? '', widget.business, buttonKey: widget.startKey)); Navigator.pop(context); } - eventBus.fire(new OnAttributePageChanged(index)); + eventBus.fire(new OnAttributePageChanged(index!)); } void _goPrevious() { - if (index - 1 >= 0) { + if (index! - 1 >= 0) { setState(() { - index = index - 1; - previousButtonEnable = index > 0; + index = index! - 1; + previousButtonEnable = index! > 0; nextButtonEnable = _checkCanGoNext(); }); - eventBus.fire(new OnAttributePageChanged(index)); + eventBus.fire(new OnAttributePageChanged(index!)); } } diff --git a/lib/widgets/mobile/mobile_blog.dart b/lib/widgets/mobile/mobile_blog.dart index 8ebc2b5..c6d6dda 100644 --- a/lib/widgets/mobile/mobile_blog.dart +++ b/lib/widgets/mobile/mobile_blog.dart @@ -18,7 +18,7 @@ import '../../widgets/mobile/MobileBottomNav.dart'; class MobileBlog extends StatefulWidget { final int businessId; - const MobileBlog({Key key, this.businessId}) : super(key: key); + const MobileBlog({Key? key, required this.businessId}) : super(key: key); @override State createState() { @@ -28,7 +28,7 @@ class MobileBlog extends StatefulWidget { } class MobileBlogState extends State { - List blogs; + List? blogs; int _page = 1; int _pageCount = 1; @@ -41,7 +41,7 @@ class MobileBlogState extends State { void _onRefresh() { _page = 1; if (blogs != null) { - blogs.clear(); + blogs?.clear(); } else { blogs = []; } @@ -82,7 +82,7 @@ class MobileBlogState extends State { enablePullUp: true, header: WaterDropHeader(), footer: CustomFooter( - builder: (BuildContext context, LoadStatus mode){ + builder: (BuildContext context, LoadStatus? mode){ Widget footer; if(mode == LoadStatus.idle) { footer = Text(S.of(context).pull_up_to_load_more); @@ -123,9 +123,9 @@ class MobileBlogState extends State { return SizedBox.shrink(); } return ListView.builder( - itemCount: blogs.length <= 1 ? 1 : blogs.length, + itemCount: blogs!.length <= 1 ? 1 : blogs!.length, itemBuilder: (BuildContext context, int i) { - if (blogs.length <= 0) { + if (blogs!.length <= 0) { return Container( padding: EdgeInsets.all(16.0), child: Center( @@ -133,7 +133,7 @@ class MobileBlogState extends State { ), ); } else { - Blog blog = blogs[i]; + Blog blog = blogs![i]; Widget w = Container( padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 16.0), @@ -243,7 +243,7 @@ class MobileBlogState extends State { if (blogs == null) { blogs = []; } - blogs.addAll((value['blogs'] as List).map((e) => Blog.fromJson(e)).toList()); + blogs!.addAll((value['blogs'] as List).map((e) => Blog.fromJson(e)).toList()); }); } }).catchError((error) { diff --git a/lib/widgets/mobile/mobile_buy_service.dart b/lib/widgets/mobile/mobile_buy_service.dart index 3e77711..54f2fcd 100644 --- a/lib/widgets/mobile/mobile_buy_service.dart +++ b/lib/widgets/mobile/mobile_buy_service.dart @@ -9,9 +9,9 @@ import '../../utils/http_util.dart'; import '../../utils/utils.dart'; class MobileBuyService extends StatefulWidget { - final Map data; + final Map? data; - const MobileBuyService(this.data, {Key key}) + const MobileBuyService(this.data, {Key? key}) : super(key: key); @override @@ -20,7 +20,7 @@ class MobileBuyService extends StatefulWidget { class MobileBuyServiceState extends State { List plans = []; - KeyValue selectedPlan; + KeyValue? selectedPlan; double price = 0.0; double tax = 0.0; double paymentAmount = 0.0; @@ -45,37 +45,37 @@ class MobileBuyServiceState extends State { ); col1.children.add( - Utils.buildLine(S.of(context).service_descritpion, widget.data['service_selections']['description'], valueSize: 16), + Utils.buildLine(S.of(context).service_descritpion, widget.data!['service_selections']['description'], valueSize: 16), ); col1.children.add( - Utils.buildLine(S.of(context).your_group, widget.data['group']['name'], valueSize: 16), + Utils.buildLine(S.of(context).your_group, widget.data!['group']['name'], valueSize: 16), ); - if (widget.data['store']['id'] != null) { + if (widget.data!['store']['id'] != null) { col1.children.add( - Utils.buildLine(S.of(context).store, widget.data['store']['name'], valueSize: 16), + Utils.buildLine(S.of(context).store, widget.data!['store']['name'], valueSize: 16), ); } - if (widget.data['domain'] != null) { + if (widget.data!['domain'] != null) { col1.children.add( - Utils.buildLine(S.of(context).domain_name, widget.data['domain'], valueSize: 16), + Utils.buildLine(S.of(context).domain_name, widget.data!['domain'], valueSize: 16), ); } - if (widget.data['exists_service'] == null) { + if (widget.data!['exists_service'] == null) { col1.children.add( Utils.buildLine(S.of(context).current_plan, 'N/A', valueSize: 16), ); } else { col1.children.add( - Utils.buildLine(S.of(context).current_plan, widget.data['exists_service']['description'], valueSize: 16), + Utils.buildLine(S.of(context).current_plan, widget.data!['exists_service']['description'], valueSize: 16), ); col1.children.add( Utils.buildLine(S.of(context).expiration_date, Utils.utcDatetimeStringToLocalDatetimeString(context, - widget.data['exists_service']['expiration_date']), + widget.data!['exists_service']['expiration_date']), valueSize: 16 ), ); @@ -97,8 +97,8 @@ class MobileBuyServiceState extends State { print('newValue $newValue'); setState(() { selectedPlan = newValue; - price = selectedPlan.value['price']; - tax = selectedPlan.value['price'] * selectedPlan.value['tax']; + price = selectedPlan!.value['price']; + tax = selectedPlan!.value['price'] * selectedPlan!.value['tax']; paymentAmount = price + tax; }); }, @@ -155,11 +155,11 @@ class MobileBuyServiceState extends State { void _submit() { if (store.state.user == null) { - Utils.requireLogin(context, returnUrl: '/buy-service/${widget.data['group']['id']}/${widget.data['service_selections']['code']}'); + Utils.requireLogin(context, returnUrl: '/buy-service/${widget.data!['group']['id']}/${widget.data!['service_selections']['code']}'); return; } - Map newData = widget.data; - newData['selected_plan'] = selectedPlan.value; + Map? newData = widget.data; + newData?['selected_plan'] = selectedPlan!.value; HttpUtil.httpPost('v1/create-service-buy-renewal-invoice', (response) { Routes.router.navigateTo(context, '/paynow/${response.data['order_id']}', replace: true); @@ -173,7 +173,7 @@ class MobileBuyServiceState extends State { @override void initState() { super.initState(); - List o = (widget.data['service_selections']['options'] as List); + List o = (widget.data!['service_selections']['options'] as List); for (int i = 0; i < o.length; i++) { Map o1 = o[i]; plans.add(new KeyValue(o1['name'], o1)); diff --git a/lib/widgets/mobile/mobile_change_mobile_or_email.dart b/lib/widgets/mobile/mobile_change_mobile_or_email.dart index ba21651..559ffc5 100644 --- a/lib/widgets/mobile/mobile_change_mobile_or_email.dart +++ b/lib/widgets/mobile/mobile_change_mobile_or_email.dart @@ -1,6 +1,6 @@ -import 'package:countdown/countdown.dart'; +import '../../vendor/countdown/countdown.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:fluttertoast/fluttertoast.dart'; @@ -15,7 +15,7 @@ import '../../utils/utils.dart'; class MobileChangeMobileOrEmail extends StatefulWidget { final bool isMobile; - const MobileChangeMobileOrEmail(this.isMobile, {Key key}) : super(key: key); + const MobileChangeMobileOrEmail(this.isMobile, {Key? key}) : super(key: key); @override State createState() { @@ -31,9 +31,9 @@ class MobileChangeMobileOrEmailState extends State { bool usernameEnable = true; final codeController = TextEditingController(); - bool enableGetCode; - String getCodeText; - bool canRegister; + bool enableGetCode = false; + String? getCodeText; + bool canRegister = false; var countDownListener; @@ -93,8 +93,8 @@ class MobileChangeMobileOrEmailState extends State { fontSize: 18.0 ), autofocus: true, - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || 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; @@ -175,7 +175,7 @@ class MobileChangeMobileOrEmailState extends State { borderRadius: BorderRadius.all(Radius.circular(10.0)), ), child: Text( - getCodeText, + '$getCodeText', style: TextStyle( color: enableGetCode ? Colors.black87 : Colors.black26, fontSize: 14.0 @@ -190,8 +190,8 @@ class MobileChangeMobileOrEmailState extends State { style: TextStyle( fontSize: 18.0 ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).verification_code_is_required; } return null; @@ -223,7 +223,7 @@ class MobileChangeMobileOrEmailState extends State { alignment: Alignment.centerRight, child: ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, ), child: Text( S.of(context).submit_to_change, @@ -256,8 +256,8 @@ class MobileChangeMobileOrEmailState extends State { } void register() { - final FormState form = _formKey.currentState; - if (form.validate()) { + final FormState? form = _formKey.currentState; + if (form != null && form.validate()) { HttpUtil.httpPost('v1/users', (response) { Utils.showMessageDialog(context, Exception(S.of(context).update_success), title: S.of(context).success, onOk: () { Navigator.of(context).pop(); @@ -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 4cc40f6..a215595 100644 --- a/lib/widgets/mobile/mobile_change_password.dart +++ b/lib/widgets/mobile/mobile_change_password.dart @@ -6,7 +6,7 @@ import '../../utils/utils.dart'; import '../../generated/l10n.dart'; class MobileChangePassword extends StatefulWidget { - const MobileChangePassword({Key key}) : super(key: key); + const MobileChangePassword({Key? key}) : super(key: key); @override State createState() { @@ -22,10 +22,10 @@ class MobileChangePasswordState extends State { final passwordController = TextEditingController(); final passwordAgainController = TextEditingController(); - bool passwordVisible; - bool passwordAgainVisible; + bool passwordVisible = false; + bool passwordAgainVisible = false; - bool canReset; + bool canReset = false; @override void initState() { @@ -87,8 +87,8 @@ class MobileChangePasswordState extends State { style: TextStyle( fontSize: 18.0 ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).current_password_is_required; } return null; @@ -141,8 +141,8 @@ class MobileChangePasswordState extends State { style: TextStyle( fontSize: 18.0 ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).password_is_required; } return null; @@ -195,8 +195,8 @@ class MobileChangePasswordState extends State { style: TextStyle( fontSize: 18.0 ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).password_is_required; } if (value.trim() != passwordController.text.trim()) { @@ -232,7 +232,7 @@ class MobileChangePasswordState extends State { alignment: Alignment.centerRight, child: ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, ), child: Text( S.of(context).submit, @@ -249,8 +249,8 @@ class MobileChangePasswordState extends State { } void resetPassword() { - final FormState form = _formKey.currentState; - if (form.validate()) { + final FormState? form = _formKey.currentState; + if (form != null && form.validate()) { HttpUtil.httpPost('v1/users', (response) { showDialog( context: context, @@ -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 8d3dd9c..5090ca2 100644 --- a/lib/widgets/mobile/mobile_checkout.dart +++ b/lib/widgets/mobile/mobile_checkout.dart @@ -32,10 +32,9 @@ import '../../utils/utils.dart'; import '../../widgets/general/sliding_up_panel.dart'; class MobileCheckout extends StatefulWidget { - final Key key; final int businessId; - const MobileCheckout(this.businessId, {this.key,}) : super(key: key); + const MobileCheckout(this.businessId, {Key? key,}) : super(key: key); @override State createState() { @@ -45,17 +44,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; + CartInfo? cartInfo; + Address? shipAddress; + bool canSubmit = false; + List? errorMessages; + List? bookingTimeList; + List? bookingDateTimeList; + List? paymentPlatforms; + TextValue? durationInTraffic; + int? selectedCoupon; double couponDiscountAmount = 0; - List coupons; + List? coupons; int peopleCount = 2; @@ -63,25 +62,25 @@ class MobileCheckoutState extends State with SingleTickerProvide String orderRemark = ''; int deliveryMethodIndex = 0; - String deliveryMethod; + String? deliveryMethod; List shippingRates = []; - ShippingRate selectedShippingRate; + ShippingRate? selectedShippingRate; List shippingMethodLabels = []; List shippingMethodIcons = []; GlobalKey _scaffoldKey = GlobalKey(); - int bookingDateIndex; - int bookingTimeIndex; - int paymentPlatformIndex; + int? bookingDateIndex; + int? bookingTimeIndex; + int? paymentPlatformIndex; GlobalKey slidingUpPanelKey = GlobalKey(); - SlidingUpPanel slidingUpPanel; + SlidingUpPanel? slidingUpPanel; PanelController panelController = PanelController(); - Widget panel; + Widget? panel; - double subtotal; + double? subtotal; TextEditingController newCouponController = TextEditingController(); @@ -102,7 +101,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( @@ -114,7 +113,7 @@ class MobileCheckoutState extends State with SingleTickerProvide ), ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, ), child: Text( S.of(context).ok, @@ -134,10 +133,10 @@ class MobileCheckoutState extends State with SingleTickerProvide } WidgetsBinding.instance.addPostFrameCallback((timeStamp) { - if(errorMessages.length > 0) { + if(errorMessages != null && errorMessages!.length > 0) { print('error: ${errorMessages.toString()}'); // _scaffoldKey.currentState.showSnackBar(errorSnackBar(errorMessages)); - ScaffoldMessenger.of(context).showSnackBar(errorSnackBar(errorMessages)); + ScaffoldMessenger.of(context).showSnackBar(errorSnackBar(errorMessages!)); } }); @@ -169,7 +168,7 @@ class MobileCheckoutState extends State with SingleTickerProvide centerTitle: true, ), body: WillPopScope( - child: slidingUpPanel, + child: slidingUpPanel!, onWillPop: () async { if (panelController != null && panelController.isPanelOpen) { panelController.close(); @@ -197,13 +196,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 +266,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'); @@ -281,7 +280,7 @@ class MobileCheckoutState extends State with SingleTickerProvide mainAxisSize: MainAxisSize.min, children: [ Text( - S.of(context).table_token(store.state.tableNumber), + S.of(context).table_token(store.state.tableNumber!), style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, @@ -308,7 +307,7 @@ class MobileCheckoutState extends State with SingleTickerProvide onChanged: (newValue) { if (mounted) { setState(() { - peopleCount = newValue; + peopleCount = newValue!; }); } }, @@ -333,7 +332,7 @@ class MobileCheckoutState extends State with SingleTickerProvide icons: shippingMethodIcons, onToggle: (index) { selectedShippingRate = null; - deliveryMethod = getShippingMethod(index); + deliveryMethod = getShippingMethod(index!); check(); }, initialLabelIndex: deliveryMethodIndex, @@ -341,7 +340,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 +354,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 +368,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 +388,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 +397,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 +405,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 +416,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 +426,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, @@ -469,7 +468,7 @@ class MobileCheckoutState extends State with SingleTickerProvide 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 ), @@ -480,7 +479,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 +503,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 +552,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 +582,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), @@ -613,7 +612,7 @@ class MobileCheckoutState extends State with SingleTickerProvide children: [ Container( child: Text( - bookingTimeList.length > 0 || bookingDateTimeList.length > 0 ? S.of(context).delivery_now : S.of(context).delivery_unavailable, + bookingTimeList!.length > 0 || bookingDateTimeList!.length > 0 ? S.of(context).delivery_now : S.of(context).delivery_unavailable, style: TextStyle( fontSize: 17.0, fontWeight: FontWeight.bold, @@ -627,9 +626,9 @@ class MobileCheckoutState extends State with SingleTickerProvide children: [ Container( 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 : '')), + 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 : '')), ), ), Container( @@ -681,7 +680,7 @@ class MobileCheckoutState extends State with SingleTickerProvide children: [ Container( child: Text( - paymentPlatforms.length == 0 ? S.of(context).pay_on_deliery : PaymentPlatform.getPaymentPlatformName(context, paymentPlatforms[paymentPlatformIndex].code), + paymentPlatforms!.length == 0 ? S.of(context).pay_on_deliery : PaymentPlatform.getPaymentPlatformName(context, paymentPlatforms![paymentPlatformIndex!].code!), ), ), Container( @@ -712,7 +711,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 +730,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 = subtotal! + cartInfo!.productList![i].totalPrice!; + column.children.add(lineItem(cartInfo!.productList![i])); } column.children.add(GestureDetector( child: Container( @@ -815,7 +814,7 @@ class MobileCheckoutState extends State with SingleTickerProvide width: 100.0, alignment: Alignment.centerRight, child: Text( - '${(subtotal - couponDiscountAmount).toStringAsFixed(2)}', + '${(subtotal! - couponDiscountAmount).toStringAsFixed(2)}', style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -826,8 +825,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 +837,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 +847,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 +875,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 +973,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, @@ -988,14 +987,14 @@ class MobileCheckoutState extends State with SingleTickerProvide children: [ Container( child: Text( - Utils.knownName(context, cartLineItem.name), + Utils.knownName(context, cartLineItem.name!), maxLines: 1, overflow: TextOverflow.ellipsis, ), ), Container( child: Text( - cartLineItem.description, + '${cartLineItem.description}', style: TextStyle( fontSize: 12.0, color: Colors.black38, @@ -1011,14 +1010,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)}', ), ), ], @@ -1050,7 +1049,7 @@ class MobileCheckoutState extends State with SingleTickerProvide if (cartInfo != null) { Utils.showLoadingDialog(context); } - CartInfo ci = Utils.getCartInfoByBusinessId(store.state.cartInfos, widget.businessId); + CartInfo? ci = Utils.getCartInfoByBusinessId(store.state.cartInfos, widget.businessId); HttpUtil.httpPost('v1/orders/check', (response) { if (cartInfo != null) { Navigator.of(context).pop(); @@ -1074,7 +1073,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 +1081,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 +1089,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') { @@ -1103,8 +1102,8 @@ class MobileCheckoutState extends State with SingleTickerProvide }, businessId: widget.businessId, body: { - 'product_list': ci.productList.toString(), - 'extra_data': ci.extraData, + 'product_list': ci?.productList.toString(), + 'extra_data': ci?.extraData, 'business_id': widget.businessId, 'pay_method': getPaymentMethod(), 'delivery': deliveryMethod, @@ -1128,8 +1127,8 @@ class MobileCheckoutState extends State with SingleTickerProvide int getPaymentMethod() { int method = 0; - if (paymentPlatforms.length > 0 && paymentPlatformIndex < paymentPlatforms.length) { - PaymentPlatform paymentPlatform = paymentPlatforms[paymentPlatformIndex]; + if (paymentPlatforms!.length > 0 && paymentPlatformIndex! < paymentPlatforms!.length) { + PaymentPlatform paymentPlatform = paymentPlatforms![paymentPlatformIndex!]; if (paymentPlatform.method == Constants.PAYMENT_METHOD_PAY_ON_DELIVERY) { return 1; } @@ -1138,10 +1137,10 @@ class MobileCheckoutState extends State with SingleTickerProvide } void afterBuild(Duration time) { - if(errorMessages.length > 0) { + if(errorMessages != null && errorMessages!.length > 0) { print('error: ${errorMessages.toString()}'); // _scaffoldKey.currentState.showSnackBar(errorSnackBar(errorMessages)); - ScaffoldMessenger.of(context).showSnackBar(errorSnackBar(errorMessages)); + ScaffoldMessenger.of(context).showSnackBar(errorSnackBar(errorMessages!)); } } @@ -1176,7 +1175,7 @@ class MobileCheckoutState extends State with SingleTickerProvide Widget getBookingTimeWidget() { Widget widget; - if (bookingTimeList.length > 0) { + if (bookingTimeList!.length > 0) { widget = Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, @@ -1208,9 +1207,9 @@ class MobileCheckoutState extends State with SingleTickerProvide ), Expanded( child: ListView.builder( - itemCount: bookingTimeList.length, + itemCount: bookingTimeList!.length, itemBuilder: (BuildContext context, int position) { - BookingTime bookingTime = bookingTimeList[position]; + BookingTime bookingTime = bookingTimeList![position]; return GestureDetector( child: Container( padding: EdgeInsets.only(left: 16.0, right: 16.0, bottom: 10.0, top: 10.0), @@ -1241,7 +1240,7 @@ class MobileCheckoutState extends State with SingleTickerProvide ) ], ); - } else if (bookingDateTimeList.length > 0) { + } else if (bookingDateTimeList!.length > 0) { widget = Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, @@ -1281,9 +1280,9 @@ class MobileCheckoutState extends State with SingleTickerProvide color: new Color(0xFFF5F5F5), child: SizedBox.expand( child: ListView.builder( - itemCount: bookingDateTimeList.length, + itemCount: bookingDateTimeList!.length, itemBuilder: (BuildContext context, int position) { - BookingDateTime bookingDateTime = bookingDateTimeList[position]; + BookingDateTime bookingDateTime = bookingDateTimeList![position]; return GestureDetector( child: Container( color: bookingDateIndex == position ? Colors.white : Colors.transparent, @@ -1310,9 +1309,9 @@ 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]; + BookingDateTime bookingDateTime = bookingDateTimeList![bookingDateIndex!]; return GestureDetector( child: Container( padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0, bottom: 12.0), @@ -1425,7 +1424,7 @@ class MobileCheckoutState extends State with SingleTickerProvide ], ); - if (paymentPlatforms.length == 0) { + if (paymentPlatforms!.length == 0) { widget.children.add(Center( child: Container( padding: EdgeInsets.all(16.0), @@ -1438,20 +1437,20 @@ class MobileCheckoutState extends State with SingleTickerProvide widget.children.add( Expanded( child:ListView.builder( - itemCount: paymentPlatforms.length, + itemCount: paymentPlatforms!.length, itemBuilder: (BuildContext context, int position) { - PaymentPlatform paymentPlatform = paymentPlatforms[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(); } @@ -1494,7 +1493,7 @@ class MobileCheckoutState extends State with SingleTickerProvide crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( - child: Util.showImage(paymentPlatform.icon, + child: Util.showImage(paymentPlatform.icon ?? '', errorWidget: (context, url, error) => Icon(Icons.broken_image, size: 50.0, color: Colors.transparent,), fit: BoxFit.cover, width: 50.0, @@ -1504,7 +1503,7 @@ class MobileCheckoutState extends State with SingleTickerProvide Container( margin: EdgeInsets.only(left: 10.0), child: Text( - PaymentPlatform.getPaymentPlatformName(context, paymentPlatform.code), + PaymentPlatform.getPaymentPlatformName(context, paymentPlatform.code ?? ''), style: TextStyle( fontSize: 18.0, fontWeight: FontWeight.bold, @@ -1541,7 +1540,7 @@ class MobileCheckoutState extends State with SingleTickerProvide String getSelectedCouponName() { if (selectedCoupon == null) { - if (coupons.length > 0) { + if (coupons!.length > 0) { return S .of(context) .please_select; @@ -1553,10 +1552,10 @@ class MobileCheckoutState extends State with SingleTickerProvide } 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)); } @@ -1632,7 +1631,7 @@ class MobileCheckoutState extends State with SingleTickerProvide ), labelText: S.of(context).enter_coupon_code, ), - validator: (String value) { + validator: (String? value) { return null; }, ), @@ -1663,7 +1662,7 @@ class MobileCheckoutState extends State with SingleTickerProvide ), ); - if (paymentPlatforms.length == 0) { + if (paymentPlatforms!.length == 0) { widget.children.add(Center( child: Container( padding: EdgeInsets.all(16.0), @@ -1675,13 +1674,13 @@ class MobileCheckoutState extends State with SingleTickerProvide } 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( @@ -1702,7 +1701,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( @@ -1739,11 +1738,11 @@ class MobileCheckoutState extends State with SingleTickerProvide }, ); } 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( @@ -1764,7 +1763,7 @@ class MobileCheckoutState extends State with SingleTickerProvide ), ), ) : BoxDecoration( - color: subtotal > coupon.minAmount ? Colors + color: subtotal! > coupon.minAmount ? Colors .transparent : Colors.black26, ), child: Row( @@ -1885,12 +1884,12 @@ class MobileCheckoutState extends State with SingleTickerProvide ), ), onTap: () { - if (subtotal > coupon.minAmount && + if (subtotal! > coupon.minAmount && mounted) { setState(() { selectedCoupon = coupon.id; if (coupon.isPercentage) { - couponDiscountAmount = subtotal * coupon.valueAmount / 100.0; + couponDiscountAmount = subtotal! * coupon.valueAmount / 100.0; } else { couponDiscountAmount = coupon.valueAmount; } @@ -1917,7 +1916,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 +1930,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, @@ -2183,7 +2182,7 @@ class MobileCheckoutState extends State with SingleTickerProvide confirmOrder() { if (!canSubmit) { // _scaffoldKey.currentState.showSnackBar(errorSnackBar(errorMessages)); - ScaffoldMessenger.of(context).showSnackBar(errorSnackBar(errorMessages)); + ScaffoldMessenger.of(context).showSnackBar(errorSnackBar(errorMessages!)); } else { Utils.showSubmitDialog(context); HttpUtil.httpPost('v1/orders', (response) { @@ -2191,19 +2190,19 @@ class MobileCheckoutState extends State with SingleTickerProvide store.dispatch(UpdateCartInfo(Utils.removeCartInfoFromCartInfoList(store.state.cartInfos, cartInfo))); eventBus.fire(OnCartInfoUpdated()); Order order = Order.fromJson(response.data); - PaymentPlatform paymentPlatform = paymentPlatforms[paymentPlatformIndex]; + PaymentPlatform paymentPlatform = paymentPlatforms![paymentPlatformIndex!]; Routes.router.navigateTo(context, '/paynow/${order.id}', replace: true); }, businessId: widget.businessId, body: { - 'cart_id': cartInfo.id, + 'cart_id': cartInfo?.id, 'remark': orderRemark, - 'booked_at': bookingTimeList.length > 0 - ? bookingTimeList[bookingTimeIndex].unixTime + 'booked_at': bookingTimeList!.length > 0 + ? bookingTimeList![bookingTimeIndex!].unixTime : ( - (bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ? + (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 690e48e..b4bcc05 100644 --- a/lib/widgets/mobile/mobile_contact_us.dart +++ b/lib/widgets/mobile/mobile_contact_us.dart @@ -15,7 +15,7 @@ import '../../widgets/general/text_link.dart'; class MobileContactUs extends StatefulWidget { final Business business; - const MobileContactUs(this.business, {Key key}) : super(key: key); + const MobileContactUs(this.business, {Key? key}) : super(key: key); @override State createState() { @@ -29,7 +29,7 @@ class MobileContactUsState extends State { String mapUrl = 'https://goo.gl/maps/M365MF5AW35n9ij67'; Completer _controller = Completer(); - LatLng _lastMapPosition; + LatLng? _lastMapPosition; final Set _markers = {}; final Set _polyLine = {}; @@ -243,7 +243,7 @@ class MobileContactUsState extends State { ), ) ); - 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), @@ -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 073aa2f..7f28d48 100644 --- a/lib/widgets/mobile/mobile_coupons.dart +++ b/lib/widgets/mobile/mobile_coupons.dart @@ -14,8 +14,7 @@ import '../../utils/utils.dart'; class MobileCoupons extends StatefulWidget { final int contactId; - final Key key; - const MobileCoupons(this.contactId, {this.key}); + const MobileCoupons(this.contactId, {Key? key}); @override State createState() { @@ -24,7 +23,7 @@ class MobileCoupons extends StatefulWidget { } class MobileCouponsState extends State { - List coupons; + List? coupons; @override Widget build(BuildContext context) { @@ -54,10 +53,10 @@ class MobileCouponsState extends State { ), ), body: ListView.builder( - itemCount: coupons.length > 0 ? coupons.length : 1, + itemCount: coupons!.length > 0 ? coupons!.length : 1, itemBuilder: (BuildContext context, int position) { - if (coupons.length > 0) { - Coupon coupon = coupons[position]; + if (coupons!.length > 0) { + Coupon coupon = coupons![position]; return Container( color: Colors.black12, child: couponWidget(coupon), @@ -97,7 +96,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 +113,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, @@ -248,7 +247,7 @@ class MobileCouponsState extends State { Container( child: ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), @@ -261,7 +260,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_download_apps.dart b/lib/widgets/mobile/mobile_download_apps.dart index ef1b1a2..362f4a7 100644 --- a/lib/widgets/mobile/mobile_download_apps.dart +++ b/lib/widgets/mobile/mobile_download_apps.dart @@ -7,7 +7,7 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dar class MobileDownloadApps extends StatefulWidget { final Map data; - MobileDownloadApps(this.data, {Key key}) : super(key: key); + MobileDownloadApps(this.data, {Key? key}) : super(key: key); @override State createState() { diff --git a/lib/widgets/mobile/mobile_edit_address.dart b/lib/widgets/mobile/mobile_edit_address.dart index 24aacf3..7ad3221 100644 --- a/lib/widgets/mobile/mobile_edit_address.dart +++ b/lib/widgets/mobile/mobile_edit_address.dart @@ -13,15 +13,15 @@ import 'package:flutter_wisetronic/store/store.dart'; import 'package:flutter_wisetronic/utils/http_util.dart'; import 'package:flutter_wisetronic/utils/utils.dart'; import 'package:fluttertoast/fluttertoast.dart'; -import 'package:gender_selection/gender_selection.dart'; +import 'package:gender_picker/gender_picker.dart'; +import 'package:gender_picker/source/enums.dart'; import '../../routes.dart'; class MobileEditAddress extends StatefulWidget { - final Key key; - final Address address; - final int businessId; - const MobileEditAddress(this.address, {this.key, int businessId}) : + final Address? address; + final int? businessId; + const MobileEditAddress(this.address, {Key? key, int? businessId}) : businessId = businessId ?? Constants.BUSINESS_ID; @override @@ -43,12 +43,12 @@ class MobileEditAddressState extends State { final emailController = TextEditingController(); final faxController = TextEditingController(); - String country; - Gender _selectedGender; + String? country; + Gender? _selectedGender; - String _selectedProvince; + String? _selectedProvince; - bool showLoading; + bool showLoading = false; @override Widget build(BuildContext context) { @@ -109,8 +109,8 @@ class MobileEditAddressState extends State { .of(context) .contact_name, ), - validator: (String value) { - if (value + validator: (String? value) { + if (value == null || value .trim() .isEmpty) { return S @@ -121,27 +121,25 @@ class MobileEditAddressState extends State { }, ), ), - GenderSelection( - maleText: S - .of(context) - .mr, - femaleText: S - .of(context) - .ms, - selectedGenderIconBackgroundColor: Colors.indigo, - checkIconAlignment: Alignment.bottomRight, - selectedGenderCheckIcon: Icons.check, - onChanged: (Gender gender) { + GenderPickerWithImage( + onChanged: (Gender? gender) { _selectedGender = gender; }, - equallyAligned: true, - animationDuration: Duration(milliseconds: 400), - isCircular: true, - isSelectedGenderIconCircular: true, - opacityOfGradient: 0.6, - padding: const EdgeInsets.all(3.0), - size: 50, + maleText: S.of(context).mr, + femaleText: S.of(context).ms, selectedGender: _selectedGender, + showOtherGender: false, + verticalAlignedText: false, + selectedGenderTextStyle: TextStyle( + color: Color(0xFF8b32a8), fontWeight: FontWeight.bold), + unSelectedGenderTextStyle: TextStyle( + color: Colors.white, fontWeight: FontWeight.normal), + equallyAligned: true, + animationDuration: Duration(milliseconds: 200), + isCircular: true, + opacityOfGradient: 0.5, + padding: const EdgeInsets.all(3), + size: 50, ), Container( padding: EdgeInsets.only( @@ -164,8 +162,8 @@ class MobileEditAddressState extends State { .of(context) .mobile_phone_number, ), - validator: (String value) { - if (value + validator: (String? value) { + if (value == null || value .trim() .isEmpty) { return S @@ -196,8 +194,8 @@ class MobileEditAddressState extends State { .of(context) .street_line_1, ), - validator: (String value) { - if (value + validator: (String? value) { + if (value == null || value .trim() .isEmpty) { return S @@ -250,8 +248,8 @@ class MobileEditAddressState extends State { .of(context) .city, ), - validator: (String value) { - if (value + validator: (String? value) { + if (value == null || value .trim() .isEmpty) { return S @@ -320,8 +318,8 @@ class MobileEditAddressState extends State { .of(context) .postal_code, ), - validator: (String value) { - if (value + validator: (String? value) { + if (value == null || value .trim() .isEmpty) { return S @@ -365,8 +363,8 @@ class MobileEditAddressState extends State { .of(context) .email, ), - validator: (String value) { - if (value.isNotEmpty && !EmailValidator.validate(value)) { + validator: (String? value) { + if (value != null && value.isNotEmpty && !EmailValidator.validate(value)) { return S .of(context) .email_is_not_valid; @@ -472,43 +470,43 @@ class MobileEditAddressState extends State { super.initState(); setState(() { showLoading = false; - _selectedProvince = widget.address.state; - cityController.text = widget.address.city; - postalCodeController.text = widget.address.zip; - streetLine1Controller.text = widget.address.addressLine1; - streetLine2Controller.text = widget.address.addressLine2; - _selectedGender = widget.address.gender == 1 ? Gender.Male : Gender.Female; - country = widget.address.country; - contactNameController.text = widget.address.contactName; - phoneController.text = widget.address.phone; - emailController.text = widget.address.email; - faxController.text = widget.address.fax; + _selectedProvince = widget.address?.state; + cityController.text = widget.address?.city ?? ''; + postalCodeController.text = widget.address?.zip ?? ''; + streetLine1Controller.text = widget.address?.addressLine1 ?? ''; + streetLine2Controller.text = widget.address?.addressLine2 ?? ''; + _selectedGender = widget.address?.gender == 1 ? Gender.Male : Gender.Female; + country = widget.address?.country; + contactNameController.text = widget.address?.contactName ?? ''; + phoneController.text = widget.address?.phone ?? ''; + emailController.text = widget.address?.email ?? ''; + faxController.text = widget.address?.fax ?? ''; }); } void _saveEditAddress() { - final FormState form = _formKey.currentState; - if (form.validate()) { + final FormState? form = _formKey.currentState; + if (form != null && form.validate()) { if (mounted) { setState(() { showLoading = true; }); } - HttpUtil.httpPatch('v1/addresses/${widget.address.id}', (response) { + HttpUtil.httpPatch('v1/addresses/${widget.address?.id}', (response) { if (mounted) { setState(() { showLoading = false; }); } eventBus.fire(OnAddressesUpdated()); - if (widget.businessId > 0) { + if (widget.businessId != null && widget.businessId! > 0) { Routes.router.navigateTo(context, '/checkout/${widget.businessId}', replace: true); } else { Navigator.of(context).pop(); } }, body: { - 'id': widget.address.id, + 'id': widget.address?.id, 'name': contactNameController.text.trim(), 'address_line1': streetLine1Controller.text.trim(), 'address_line2': streetLine2Controller.text.trim(), @@ -538,7 +536,7 @@ class MobileEditAddressState extends State { showLoading = true; }); } - HttpUtil.httpDelete('v1/addresses/${widget.address.id}', (response) { + HttpUtil.httpDelete('v1/addresses/${widget.address?.id}', (response) { if (mounted) { setState(() { showLoading = false; diff --git a/lib/widgets/mobile/mobile_forgot_password.dart b/lib/widgets/mobile/mobile_forgot_password.dart index 68e59b4..e6f0603 100644 --- a/lib/widgets/mobile/mobile_forgot_password.dart +++ b/lib/widgets/mobile/mobile_forgot_password.dart @@ -1,5 +1,5 @@ -import 'package:countdown/countdown.dart'; +import '../../vendor/countdown/countdown.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:fluttertoast/fluttertoast.dart'; @@ -12,7 +12,7 @@ import '../../utils/http_util.dart'; import '../../utils/utils.dart'; class MobileForgotPassword extends StatefulWidget { - const MobileForgotPassword({Key key}) : super(key: key); + const MobileForgotPassword({Key? key}) : super(key: key); @override State createState() { @@ -28,9 +28,9 @@ class MobileForgotPasswordState extends State { bool usernameEnable = true; final codeController = TextEditingController(); - bool enableGetCode; - String getCodeText; - bool canRegister; + bool enableGetCode = false; + String? getCodeText; + bool canRegister = false; var countDownListener; @@ -90,8 +90,8 @@ class MobileForgotPasswordState extends State { fontSize: 18.0 ), autofocus: true, - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).mobile_or_email_is_required; } return null; @@ -158,7 +158,7 @@ class MobileForgotPasswordState extends State { borderRadius: BorderRadius.all(Radius.circular(10.0)), ), child: Text( - getCodeText, + '${getCodeText}', style: TextStyle( color: enableGetCode ? Colors.black87 : Colors.black26, fontSize: 12.0 @@ -173,8 +173,8 @@ class MobileForgotPasswordState extends State { style: TextStyle( fontSize: 18.0 ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).verification_code_is_required; } return null; @@ -206,7 +206,7 @@ class MobileForgotPasswordState extends State { alignment: Alignment.centerRight, child: ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, ), child: Text( S.of(context).verify, @@ -239,8 +239,8 @@ class MobileForgotPasswordState extends State { } void register() { - final FormState form = _formKey.currentState; - if (form.validate()) { + final FormState? form = _formKey.currentState; + if (form != null && form.validate()) { HttpUtil.httpPost('v1/users', (response) { Routes.router.navigateTo(context, '/reset-password/${usernameController.text.trim()}/${codeController.text.trim()}', replace: true); }, diff --git a/lib/widgets/mobile/mobile_igoshow_learn_more.dart b/lib/widgets/mobile/mobile_igoshow_learn_more.dart index 3aaee3b..520201f 100644 --- a/lib/widgets/mobile/mobile_igoshow_learn_more.dart +++ b/lib/widgets/mobile/mobile_igoshow_learn_more.dart @@ -5,7 +5,7 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dar class MobileiGoShowLearnMore extends StatefulWidget { final Map data; - const MobileiGoShowLearnMore(this.data, {Key key}) : super(key: key); + const MobileiGoShowLearnMore(this.data, {Key? key}) : super(key: key); @override State createState() { diff --git a/lib/widgets/mobile/mobile_index_carousel.dart b/lib/widgets/mobile/mobile_index_carousel.dart index c506484..30f4caf 100644 --- a/lib/widgets/mobile/mobile_index_carousel.dart +++ b/lib/widgets/mobile/mobile_index_carousel.dart @@ -7,7 +7,7 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dar class MobileIndexCarousel extends StatefulWidget { final List galleries; - const MobileIndexCarousel(this.galleries, {Key key}) : super(key: key); + const MobileIndexCarousel(this.galleries, {Key? key}) : super(key: key); @override State createState() { diff --git a/lib/widgets/mobile/mobile_index_main_content_1.dart b/lib/widgets/mobile/mobile_index_main_content_1.dart index 375d927..82b2b2b 100644 --- a/lib/widgets/mobile/mobile_index_main_content_1.dart +++ b/lib/widgets/mobile/mobile_index_main_content_1.dart @@ -3,9 +3,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_wisetronic/generated/l10n.dart'; class MobileIndexMainContent1 extends StatefulWidget { - final String message; + final String? message; - const MobileIndexMainContent1(this.message, {Key key}) : super(key: key); + const MobileIndexMainContent1(this.message, {Key? key}) : super(key: key); @override State createState() { @@ -22,7 +22,7 @@ class MobileIndexMainContent1State extends State { padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 20.0), child: Container( child: Text( - widget.message, + widget.message ?? '', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, diff --git a/lib/widgets/mobile/mobile_index_main_content_2.dart b/lib/widgets/mobile/mobile_index_main_content_2.dart index 57f3e3c..e58ae71 100644 --- a/lib/widgets/mobile/mobile_index_main_content_2.dart +++ b/lib/widgets/mobile/mobile_index_main_content_2.dart @@ -5,9 +5,9 @@ import '../../widgets/general/text_link.dart'; import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dart'; class MobileIndexMainContent2 extends StatefulWidget { - final Map content; + final Map? content; - const MobileIndexMainContent2(this.content, {Key key}) : super(key: key); + const MobileIndexMainContent2(this.content, {Key? key}) : super(key: key); @override State createState() { @@ -33,7 +33,7 @@ class MobileIndexMainContent2State extends State { Container( padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0), child: Text( - '${widget.content['minipos']}', + '${widget.content?['minipos']}', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, @@ -44,7 +44,7 @@ class MobileIndexMainContent2State extends State { Container( padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0), child: Text( - '${widget.content['point_of_sale_system_solution']}', + '${widget.content?['point_of_sale_system_solution']}', style: TextStyle( fontSize: 15.0, color: Colors.grey, @@ -58,7 +58,7 @@ class MobileIndexMainContent2State extends State { Container( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Util.showImage( - 'https:${widget.content['minipos_image']['image']}', + 'https:${widget.content?['minipos_image']['image']}', fit: BoxFit.fitWidth ), ), @@ -71,7 +71,7 @@ class MobileIndexMainContent2State extends State { Column col = Column( children: [], ); - for (int i = 0; i < (widget.content['minipos_features'] as List).length; i++) { + for (int i = 0; i < (widget.content?['minipos_features'] as List).length; i++) { col.children.add(Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -88,7 +88,7 @@ class MobileIndexMainContent2State extends State { width: MediaQuery.of(context).size.width - 40.0, padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0), child: Text( - '${(widget.content['minipos_features'] as List)[i]}', + '${(widget.content?['minipos_features'] as List)[i]}', style: TextStyle( color: Colors.black54, ), diff --git a/lib/widgets/mobile/mobile_index_main_content_3.dart b/lib/widgets/mobile/mobile_index_main_content_3.dart index 2283512..4815f44 100644 --- a/lib/widgets/mobile/mobile_index_main_content_3.dart +++ b/lib/widgets/mobile/mobile_index_main_content_3.dart @@ -5,9 +5,9 @@ import '../../widgets/general/text_link.dart'; import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dart'; class MobileIndexMainContent3 extends StatefulWidget { - final Map content; + final Map? content; - const MobileIndexMainContent3(this.content, {Key key}) : super(key: key); + const MobileIndexMainContent3(this.content, {Key? key}) : super(key: key); @override State createState() { @@ -33,7 +33,7 @@ class MobileIndexMainContent3State extends State { Container( padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0), child: Text( - '${widget.content['igoshow']}', + '${widget.content?['igoshow']}', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, @@ -44,7 +44,7 @@ class MobileIndexMainContent3State extends State { Container( padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0), child: Text( - '${widget.content['igoshow_solution']}', + '${widget.content?['igoshow_solution']}', style: TextStyle( fontSize: 15.0, color: Colors.grey, @@ -58,7 +58,7 @@ class MobileIndexMainContent3State extends State { Container( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Util.showImage( - 'https:${widget.content['igoshow_image']['image']}', + 'https:${widget.content?['igoshow_image']['image']}', fit: BoxFit.fitWidth ), ), @@ -74,7 +74,7 @@ class MobileIndexMainContent3State extends State { Column col = Column( children: [], ); - for (int i = 0; i < (widget.content['igoshow_features'] as List).length; i++) { + for (int i = 0; i < (widget.content?['igoshow_features'] as List).length; i++) { col.children.add(Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -91,7 +91,7 @@ class MobileIndexMainContent3State extends State { width: MediaQuery.of(context).size.width - 40.0, padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0), child: Text( - '${(widget.content['igoshow_features'] as List)[i]}', + '${(widget.content?['igoshow_features'] as List)[i]}', style: TextStyle( color: Colors.black54, ), diff --git a/lib/widgets/mobile/mobile_login.dart b/lib/widgets/mobile/mobile_login.dart index c048645..d2bc693 100644 --- a/lib/widgets/mobile/mobile_login.dart +++ b/lib/widgets/mobile/mobile_login.dart @@ -11,9 +11,8 @@ import '../../store/actions.dart'; import '../../store/store.dart'; class MobileLogin extends StatefulWidget { - final Key key; - const MobileLogin({this.key}) : super(key: key); + const MobileLogin({Key? key}) : super(key: key); @override State createState() { @@ -26,9 +25,9 @@ class MobileLoginState extends State { final usernameController = TextEditingController(); final passwordController = TextEditingController(); - bool passwordVisible; + bool passwordVisible = false; - bool onSubmitting; + bool onSubmitting = false; @override void initState() { @@ -103,8 +102,8 @@ class MobileLoginState extends State { fontSize: 18.0 ), autofocus: true, - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).this_field_is_required; } return null; @@ -143,8 +142,8 @@ class MobileLoginState extends State { fontSize: 18.0 ), obscureText: passwordVisible, - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).password_is_required; } return null; @@ -196,7 +195,7 @@ class MobileLoginState extends State { padding: EdgeInsets.only(top: 20.0, left: 16.0, right: 16.0, bottom: 20.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, ), child: Text( S.of(context).login, @@ -226,8 +225,8 @@ class MobileLoginState extends State { } void signIn() { - final FormState form = _formKey.currentState; - if (form.validate()) { + final FormState? form = _formKey.currentState; + if (form != null && form.validate()) { if (mounted) { setState(() { onSubmitting = true; @@ -239,19 +238,15 @@ class MobileLoginState extends State { print('response $response'); User user = User.fromJson(response.data['user']); store.dispatch(UpdateCurrentUser(user)); - Utils.getBox().then((box) { - box.put(Constants.KEY_USER_ID, response.data['user_id']); - box.put(Constants.KEY_ACCESS_TOKEN, response.data['access_token']); - if (store.state.redirectRoute != null) { - Routes.router.navigateTo(context, store.state.redirectRoute, replace: true); - store.dispatch(UpdateRedirectRoute(null)); - } else { - Routes.router.navigateTo( - context, '/me', replace: true, clearStack: false); - } - }).catchError((error) { - Utils.showMessageDialog(context, error); - }); + Utils.prefs?.setString(Constants.KEY_USER_ID, response.data['user_id']); + Utils.prefs?.setString(Constants.KEY_ACCESS_TOKEN, response.data['access_token']); + if (store.state.redirectRoute != null) { + Routes.router.navigateTo(context, store.state.redirectRoute!, replace: true); + store.dispatch(UpdateRedirectRoute(null)); + } else { + Routes.router.navigateTo( + context, '/me', replace: true, clearStack: false); + } }, queryParameters: { 'client_id': '${Utils.getPlatformName()}', diff --git a/lib/widgets/mobile/mobile_me.dart b/lib/widgets/mobile/mobile_me.dart index e5a0ff1..d55869f 100644 --- a/lib/widgets/mobile/mobile_me.dart +++ b/lib/widgets/mobile/mobile_me.dart @@ -20,14 +20,13 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dart'; import '../../utils/utils.dart'; -MediaQueryData mediaQuery; -double statusBarHeight; -double screenHeight; +MediaQueryData? mediaQuery; +double? statusBarHeight; +double? screenHeight; class MobileMe extends StatefulWidget { - final Key key; - const MobileMe({this.key}) : super(key: key); + const MobileMe({Key? key}) : super(key: key); @override State createState() { @@ -36,18 +35,18 @@ class MobileMe extends StatefulWidget { } class MobileMeState extends State { - int userId; - String accessToken; + int? userId; + String? accessToken; - bool isLoading; - User _user; + bool isLoading = false; + User? _user; - ShopScrollCoordinator _shopCoordinator; - ShopScrollController _pageScrollController; + ShopScrollCoordinator? _shopCoordinator; + ShopScrollController? _pageScrollController; final double _sliverAppBarInitHeight = 165.0; final double _appBarHeight = 85.0; - ShopScrollController _listScrollController1; + ShopScrollController? _listScrollController1; @override Widget build(BuildContext context) { @@ -65,16 +64,16 @@ class MobileMeState extends State { } mediaQuery ??= MediaQuery.of(context); - screenHeight ??= mediaQuery.size.height; - statusBarHeight ??= mediaQuery.padding.top; + screenHeight ??= mediaQuery!.size.height; + statusBarHeight ??= mediaQuery!.padding.top; _pageScrollController ??= - _shopCoordinator.pageScrollController(_sliverAppBarInitHeight * -1.0); - _shopCoordinator.pinnedHeaderSliverHeightBuilder ??= () { - return statusBarHeight + kToolbarHeight + _appBarHeight; + _shopCoordinator!.pageScrollController(_sliverAppBarInitHeight * -1.0); + _shopCoordinator!.pinnedHeaderSliverHeightBuilder ??= () { + return statusBarHeight! + kToolbarHeight + _appBarHeight; }; - _listScrollController1 = _shopCoordinator.newChildScrollController(); + _listScrollController1 = _shopCoordinator?.newChildScrollController(); Widget userInfo = GestureDetector( child: Container( @@ -88,9 +87,9 @@ class MobileMeState extends State { children: [ Container( margin: EdgeInsets.only(right: 5.0), - child: _user != null && _user.avatarUrl.isNotEmpty + child: _user != null && _user!.avatarUrl.isNotEmpty ? Util.showImage( - 'https:${_user.avatarUrl}', + 'https:${_user!.avatarUrl}', width: 60, height: 60, fit: BoxFit.fill, @@ -116,7 +115,7 @@ class MobileMeState extends State { Container( child: Text( _user != null - ? _user.nickname + ? _user!.nickname : S.of(context).please_login, style: TextStyle( color: Theme.of(context).scaffoldBackgroundColor, @@ -142,7 +141,7 @@ class MobileMeState extends State { Container( child: Text( _user != null - ? Utils.safePhoneNumber(_user.mobile) + ? Utils.safePhoneNumber(_user!.mobile) : '', style: TextStyle( color: @@ -180,7 +179,7 @@ class MobileMeState extends State { ); Listener listener = Listener( - onPointerUp: _shopCoordinator.onPointerUp, + onPointerUp: _shopCoordinator?.onPointerUp, child: CustomScrollView( controller: _pageScrollController, physics: ClampingScrollPhysics(), @@ -219,7 +218,7 @@ class MobileMeState extends State { Container( child: Text( _user != null - ? '${_user.wallet.toStringAsFixed(2)}' + ? '${_user!.wallet.toStringAsFixed(2)}' : '0.00', style: TextStyle( fontSize: 24.0, @@ -262,7 +261,7 @@ class MobileMeState extends State { children: [ Container( child: Text( - _user != null ? '${_user.coupon}' : '0', + _user != null ? '${_user!.coupon}' : '0', style: TextStyle( fontSize: 24.0, color: Colors.orangeAccent, @@ -296,7 +295,7 @@ class MobileMeState extends State { onTap: () { if (_user != null) { Routes.router - .navigateTo(context, '/coupons/${_user.id}'); + .navigateTo(context, '/coupons/${_user!.id}'); } else { _pleaseLoginToast(); } @@ -312,7 +311,7 @@ class MobileMeState extends State { children: [ Container( child: Text( - _user != null ? '${_user.points}' : '0', + _user != null ? '${_user!.points}' : '0', style: TextStyle( fontSize: 24.0, color: Colors.lightGreen, @@ -350,7 +349,7 @@ class MobileMeState extends State { controller: _listScrollController1, itemCount: 7, itemBuilder: (BuildContext context, int i) { - Widget item; + Widget? item; switch (i) { case 0: item = GestureDetector( @@ -671,7 +670,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) { @@ -687,7 +686,7 @@ class MobileMeState extends State { ), ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, textStyle: TextStyle( color: Colors.white, ), @@ -816,9 +815,9 @@ class MobileMeState extends State { class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { _SliverAppBarDelegate({ - @required this.minHeight, - @required this.maxHeight, - @required this.child, + required this.minHeight, + required this.maxHeight, + required this.child, }); final double minHeight; diff --git a/lib/widgets/mobile/mobile_minipos_learn_more.dart b/lib/widgets/mobile/mobile_minipos_learn_more.dart index 337796c..8da55c1 100644 --- a/lib/widgets/mobile/mobile_minipos_learn_more.dart +++ b/lib/widgets/mobile/mobile_minipos_learn_more.dart @@ -4,7 +4,7 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dar class MobileMiniPosLearnMore extends StatefulWidget { final Map data; - const MobileMiniPosLearnMore(this.data, {Key key}) : super(key: key); + const MobileMiniPosLearnMore(this.data, {Key? key}) : super(key: key); @override State createState() { diff --git a/lib/widgets/mobile/mobile_my_addresses.dart b/lib/widgets/mobile/mobile_my_addresses.dart index fc26f30..2e1877b 100644 --- a/lib/widgets/mobile/mobile_my_addresses.dart +++ b/lib/widgets/mobile/mobile_my_addresses.dart @@ -17,7 +17,7 @@ import '../../routes.dart'; class MobileMyAddresses extends StatefulWidget { final int businessId; - const MobileMyAddresses({Key key, this.businessId}) : super(key: key); + const MobileMyAddresses({Key? key, required this.businessId}) : super(key: key); @override State createState() { @@ -27,7 +27,7 @@ class MobileMyAddresses extends StatefulWidget { } class MobileMyAddressesState extends State { - List
addresses; + List
? addresses; @override Widget build(BuildContext context) { @@ -70,9 +70,9 @@ class MobileMyAddressesState extends State { ], ), body: ListView.builder( - itemCount: addresses.length <= 1 ? 1 : addresses.length, + itemCount: addresses!.length <= 1 ? 1 : addresses!.length, itemBuilder: (BuildContext context, int i) { - if (addresses.length <= 0) { + if (addresses!.length <= 0) { return Container( padding: EdgeInsets.all(16.0), child: Center( @@ -80,7 +80,7 @@ class MobileMyAddressesState extends State { ), ); } else { - Address address = addresses[i]; + Address address = addresses![i]; return Container( padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 16.0), @@ -102,7 +102,7 @@ class MobileMyAddressesState extends State { children: [ Container( child: Text( - address.addressLine1, + '${address.addressLine1}', style: TextStyle( fontSize: 19.0, ), @@ -110,7 +110,7 @@ class MobileMyAddressesState extends State { ), Container( child: Text( - address.addressLine2, + '${address.addressLine2}', style: TextStyle( fontSize: 13.0, color: Colors.grey, @@ -120,7 +120,7 @@ class MobileMyAddressesState extends State { Container( margin: EdgeInsets.only(top: 10.0), child: Text( - '${address.contactName} ${Utils.safePhoneNumber(address.phone)}', + '${address.contactName} ${Utils.safePhoneNumber(address.phone ?? '')}', style: TextStyle( fontSize: 15.0, color: Colors.black87, diff --git a/lib/widgets/mobile/mobile_my_cards.dart b/lib/widgets/mobile/mobile_my_cards.dart index 38481bb..b1c1dd8 100644 --- a/lib/widgets/mobile/mobile_my_cards.dart +++ b/lib/widgets/mobile/mobile_my_cards.dart @@ -13,8 +13,7 @@ import '../../utils/http_util.dart'; import '../../utils/utils.dart'; class MobileMyCards extends StatefulWidget { - final Key key; - const MobileMyCards({this.key}); + const MobileMyCards({Key? key}); @override State createState() { @@ -24,9 +23,9 @@ class MobileMyCards extends StatefulWidget { } class MyCardsState extends State { - User _user; + User? _user; - bool isSubmitting; + bool isSubmitting = false; @override Widget build(BuildContext context) { @@ -44,9 +43,9 @@ class MyCardsState extends State { backgroundColor: Theme.of(context).primaryColor, ), body: ListView.builder( - itemCount: _user.stripePaymentMethods.length, + itemCount: _user!.stripePaymentMethods.length, itemBuilder: (BuildContext context, int position) { - StripePaymentMethod paymentMethod = _user.stripePaymentMethods[position]; + StripePaymentMethod paymentMethod = _user!.stripePaymentMethods[position]; return cardWidget(paymentMethod); } ), @@ -116,7 +115,7 @@ class MyCardsState extends State { TextButton( child: Text(S.of(context).cancel), style: TextButton.styleFrom( - primary: Theme.of(context).primaryColor, + foregroundColor: Theme.of(context).primaryColor, ), onPressed: () { Navigator.of(context).pop(); diff --git a/lib/widgets/mobile/mobile_my_support.dart b/lib/widgets/mobile/mobile_my_support.dart index e864c8d..7ad85db 100644 --- a/lib/widgets/mobile/mobile_my_support.dart +++ b/lib/widgets/mobile/mobile_my_support.dart @@ -18,7 +18,7 @@ import '../../widgets/mobile/MobileBottomNav.dart'; class MobileMySupport extends StatefulWidget { final int businessId; - const MobileMySupport({Key key, this.businessId}) : super(key: key); + const MobileMySupport({Key? key, required this.businessId}) : super(key: key); @override State createState() { @@ -28,7 +28,7 @@ class MobileMySupport extends StatefulWidget { } class MobileMySupportState extends State { - List tickets; + List? tickets; int _page = 1; int _pageCount = 1; @@ -41,7 +41,7 @@ class MobileMySupportState extends State { void _onRefresh() { _page = 1; if (tickets != null) { - tickets.clear(); + tickets?.clear(); } else { tickets = []; } @@ -101,7 +101,7 @@ class MobileMySupportState extends State { enablePullUp: true, header: WaterDropHeader(), footer: CustomFooter( - builder: (BuildContext context, LoadStatus mode){ + builder: (BuildContext context, LoadStatus? mode){ Widget footer; if(mode == LoadStatus.idle) { footer = Text(S.of(context).pull_up_to_load_more); @@ -143,9 +143,9 @@ class MobileMySupportState extends State { return SizedBox.shrink(); } return ListView.builder( - itemCount: tickets.length <= 1 ? 1 : tickets.length, + itemCount: tickets!.length <= 1 ? 1 : tickets!.length, itemBuilder: (BuildContext context, int i) { - if (tickets.length <= 0) { + if (tickets!.length <= 0) { return Container( padding: EdgeInsets.all(16.0), child: Center( @@ -153,7 +153,7 @@ class MobileMySupportState extends State { ), ); } else { - Ticket ticket = tickets[i]; + Ticket ticket = tickets![i]; return GestureDetector( onTap: () { @@ -273,7 +273,7 @@ class MobileMySupportState extends State { if (tickets == null) { tickets = []; } - tickets.addAll((value['tickets'] as List).map((e) => Ticket.fromJson(e)).toList()); + tickets!.addAll((value['tickets'] as List).map((e) => Ticket.fromJson(e)).toList()); }); } }).catchError((error) { diff --git a/lib/widgets/mobile/mobile_navigation_drawer.dart b/lib/widgets/mobile/mobile_navigation_drawer.dart index 66f527c..ea3f1dd 100644 --- a/lib/widgets/mobile/mobile_navigation_drawer.dart +++ b/lib/widgets/mobile/mobile_navigation_drawer.dart @@ -13,7 +13,7 @@ import '../../widgets/mobile/mobile_navigation_drawer_header.dart'; import '../../constants.dart'; class MobileNavigationDrawer extends StatefulWidget { - const MobileNavigationDrawer({Key key}) : super(key: key); + const MobileNavigationDrawer({Key? key}) : super(key: key); @override State createState() { @@ -23,11 +23,11 @@ class MobileNavigationDrawer extends StatefulWidget { } class MobileNavigationDrawerState extends State { - User _user; + User? _user; @override Widget build(BuildContext context) { - String currentRoute = ModalRoute.of(context).settings.name; + String? currentRoute = ModalRoute.of(context)?.settings.name; return Container( width: 200.0, diff --git a/lib/widgets/mobile/mobile_navigationbar.dart b/lib/widgets/mobile/mobile_navigationbar.dart index e49a51d..ca6a39a 100644 --- a/lib/widgets/mobile/mobile_navigationbar.dart +++ b/lib/widgets/mobile/mobile_navigationbar.dart @@ -10,11 +10,11 @@ import '../../widgets/general/navigationbar_logo.dart'; import '../../routes.dart'; class MobileNavigationBar extends StatefulWidget { - final String title; - final bool back; - final bool toHome; - final bool showMe; - const MobileNavigationBar({Key key, this.title, this.back, this.toHome, this.showMe}) : super(key: key); + final String? title; + final bool? back; + final bool? toHome; + final bool? showMe; + const MobileNavigationBar({Key? key, this.title, this.back, this.toHome, this.showMe}) : super(key: key); @override State createState() { @@ -24,19 +24,19 @@ class MobileNavigationBar extends StatefulWidget { } class MobileNavigationBarState extends State { - User _user; + User? _user; @override Widget build(BuildContext context) { return AppBar( - leading: widget.back ? + leading: widget.back != null && widget.back! ? IconButton( icon: Icon( Icons.arrow_back_ios, color: Colors.white, ), onPressed: () { - if (widget.toHome) { + if (widget.toHome != null && widget.toHome!) { Routes.router.navigateTo(context, '/', clearStack: true); } else { Routes.router.pop(context); @@ -53,7 +53,7 @@ class MobileNavigationBarState extends State { }, ), title: Container( - child: widget.title.isNotEmpty ? + child: widget.title != null && widget.title!.isNotEmpty ? Container( child: Text( '${widget.title}', diff --git a/lib/widgets/mobile/mobile_new_address.dart b/lib/widgets/mobile/mobile_new_address.dart index 229e2a1..f0986f3 100644 --- a/lib/widgets/mobile/mobile_new_address.dart +++ b/lib/widgets/mobile/mobile_new_address.dart @@ -1,7 +1,8 @@ import 'package:email_validator/email_validator.dart'; import 'package:flutter/material.dart'; -import 'package:gender_selection/gender_selection.dart'; +import 'package:gender_picker/gender_picker.dart'; +import 'package:gender_picker/source/enums.dart'; import '../../generated/l10n.dart'; import '../../models/located_address.dart'; @@ -11,10 +12,9 @@ import '../../store/store.dart'; import '../../utils/http_util.dart'; class MobileNewAddress extends StatefulWidget { - final Key key; - final LocatedAddress locatedAddress; - final int businessId; - const MobileNewAddress({this.key, this.locatedAddress, this.businessId}) : super(key: key); + final LocatedAddress? locatedAddress; + final int? businessId; + const MobileNewAddress({Key? key, this.locatedAddress, this.businessId}) : super(key: key); @override State createState() { @@ -36,9 +36,9 @@ class MobileNewAddressState extends State { final faxController = TextEditingController(); String country = 'CA'; - Gender _selectedGender; + Gender? _selectedGender; - String _selectedProvince; + String? _selectedProvince; List provinces = [ 'Ontario', @@ -96,31 +96,33 @@ class MobileNewAddressState extends State { ), labelText: S.of(context).contact_name, ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).contact_name_is_required; } return null; }, ), ), - GenderSelection( - maleText: S.of(context).mr, - femaleText: S.of(context).ms, - selectedGenderIconBackgroundColor: Colors.indigo, - checkIconAlignment: Alignment.bottomRight, - selectedGenderCheckIcon: Icons.check, - onChanged: (Gender gender) { + GenderPickerWithImage( + onChanged: (Gender? gender) { _selectedGender = gender; }, - equallyAligned: true, - animationDuration: Duration(milliseconds: 400), - isCircular: true, - isSelectedGenderIconCircular: true, - opacityOfGradient: 0.6, - padding: const EdgeInsets.all(3.0), - size: 50, + maleText: S.of(context).mr, + femaleText: S.of(context).ms, selectedGender: _selectedGender, + showOtherGender: false, + verticalAlignedText: false, + selectedGenderTextStyle: TextStyle( + color: Color(0xFF8b32a8), fontWeight: FontWeight.bold), + unSelectedGenderTextStyle: TextStyle( + color: Colors.white, fontWeight: FontWeight.normal), + equallyAligned: true, + animationDuration: Duration(milliseconds: 200), + isCircular: true, + opacityOfGradient: 0.5, + padding: const EdgeInsets.all(3), + size: 50, ), Container( padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 16.0, bottom: 0.0), @@ -140,8 +142,8 @@ class MobileNewAddressState extends State { ), labelText: S.of(context).mobile_phone_number, ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).mobile_phone_number_is_required; } return null; @@ -165,8 +167,8 @@ class MobileNewAddressState extends State { ), labelText: S.of(context).street_line_1, ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).street_line_1_is_required; } return null; @@ -209,8 +211,8 @@ class MobileNewAddressState extends State { ), labelText: S.of(context).city, ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).city_is_required; } return null; @@ -255,8 +257,8 @@ class MobileNewAddressState extends State { ), labelText: S.of(context).postal_code, ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).postal_code_is_required; } return null; @@ -290,8 +292,8 @@ class MobileNewAddressState extends State { ), labelText: S.of(context).email, ), - validator: (String value) { - if (value.isNotEmpty && !EmailValidator.validate(value)) { + validator: (String? value) { + if (value != null && value.isNotEmpty && !EmailValidator.validate(value)) { return S.of(context).email_is_not_valid; } return null; @@ -348,15 +350,15 @@ class MobileNewAddressState extends State { super.initState(); setState(() { if (widget.locatedAddress != null) { - if (provinces.contains(widget.locatedAddress.province)) { - _selectedProvince = widget.locatedAddress.province; + if (provinces.contains(widget.locatedAddress!.province)) { + _selectedProvince = widget.locatedAddress!.province; } - 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.streetName; + 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!.streetName; } else { _selectedProvince = 'Ontario'; } @@ -366,11 +368,11 @@ class MobileNewAddressState extends State { } void _saveNewAddress() { - final FormState form = _formKey.currentState; - if (form.validate()) { + final FormState? form = _formKey.currentState; + if (form != null && form.validate()) { HttpUtil.httpPost('v1/addresses', (response) { - if (widget.businessId > 0) { + if (widget.businessId! > 0) { Routes.router.navigateTo(context, '/checkout/${widget.businessId}', replace: true); } else { Routes.router.navigateTo(context, '/my-addresses/${widget.businessId}', replace: true); diff --git a/lib/widgets/mobile/mobile_new_comment.dart b/lib/widgets/mobile/mobile_new_comment.dart index a315ebf..fae0b79 100644 --- a/lib/widgets/mobile/mobile_new_comment.dart +++ b/lib/widgets/mobile/mobile_new_comment.dart @@ -1,9 +1,9 @@ -import 'package:badges/badges.dart'; +import 'package:badges/badges.dart' as badges; import 'package:flutter/material.dart'; import 'package:percent_indicator/linear_percent_indicator.dart'; -import 'package:smooth_star_rating/smooth_star_rating.dart'; +import 'package:smooth_star_rating_nsafe/smooth_star_rating.dart'; import '../../events/eventbus.dart'; import '../../events/events.dart'; @@ -19,9 +19,8 @@ import '../../utils/utils.dart'; class MobileNewComment extends StatefulWidget { - final Key key; final int orderId; - const MobileNewComment(this.orderId, {this.key}); + const MobileNewComment(this.orderId, {Key? key}); @override State createState() { @@ -31,13 +30,13 @@ class MobileNewComment extends StatefulWidget { } class MobileNewCommentState extends State { - Comment comment; + Comment? comment; - bool _showProgress; + bool _showProgress = false; - double _progress; + double? _progress; - double rating; + double? rating; bool isSubmitting = false; @@ -112,13 +111,8 @@ class MobileNewCommentState extends State { padding: EdgeInsets.only(left: 20.0, right: 20.0, top: 16.0, bottom: 16.0), child: SmoothStarRating( allowHalfRating: false, - onRated: (v) { - setState(() { - rating = v; - }); - }, starCount: 5, - rating: rating, + rating: rating!, size: 40.0, filledIconData: Icons.star, color: Colors.green, @@ -167,13 +161,13 @@ class MobileNewCommentState extends State { children: [], ); - if (comment != null && comment.images.length > 0) { - for (ProductImage image in comment.images) { + if (comment != null && comment!.images.length > 0) { + for (ProductImage image in comment!.images) { row.children.add( Container( padding: EdgeInsets.only(left: 10.0), - child: Badge( - position: BadgePosition.topEnd(top: -10.0, end: -6.0), + child: badges.Badge( + position: badges.BadgePosition.topEnd(top: -10.0, end: -6.0), badgeContent: Container( child: Text( '-', @@ -210,7 +204,7 @@ class MobileNewCommentState extends State { Navigator.of(context).pop(); }, style: TextButton.styleFrom( - primary: Theme.of(context).primaryColor, + foregroundColor: Theme.of(context).primaryColor, ), ), TextButton( @@ -239,7 +233,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,13 +258,13 @@ class MobileNewCommentState extends State { ), ), onTap: () { - if (comment == null || comment.images.length < 3) { + if (comment == null || comment!.images.length < 3) { showDialog( context: mainContext, barrierDismissible: true, builder: (BuildContext context) { - return Util().getPicture(mainContext, store.state.user, - commentId: comment != null ? comment.id : 0, + return Util().getPicture(mainContext, store.state.user!, + commentId: comment != null ? comment!.id : 0, orderId: widget.orderId); } ); @@ -290,7 +284,7 @@ class MobileNewCommentState extends State { visible: _showProgress, child: LinearPercentIndicator( lineHeight: 10.0, - percent: _progress, + percent: _progress!, backgroundColor: Colors.transparent, progressColor: Colors.blue, linearStrokeCap: LinearStrokeCap.butt, @@ -329,7 +323,7 @@ class MobileNewCommentState extends State { } }, queryParameters: { - 'comment_id': comment != null ? comment.id : 0, + 'comment_id': comment != null ? comment!.id : 0, }, ).catchError((error) { Utils.showMessageDialog(context, error); @@ -356,9 +350,9 @@ class MobileNewCommentState extends State { isFormData: true, body: { 'order_id': widget.orderId, - 'comment_id': comment != null ? comment.id : 0, + 'comment_id': comment != null ? comment!.id : 0, 'content': commentController.text, - 'rating': rating.round(), + 'rating': rating!.round(), }, ).catchError((error) { if (isSubmitting) { diff --git a/lib/widgets/mobile/mobile_new_ticket.dart b/lib/widgets/mobile/mobile_new_ticket.dart index 05ec49a..08e3e90 100644 --- a/lib/widgets/mobile/mobile_new_ticket.dart +++ b/lib/widgets/mobile/mobile_new_ticket.dart @@ -1,5 +1,5 @@ -import 'package:badges/badges.dart'; +import 'package:badges/badges.dart' as badges; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,10 +17,9 @@ import '../../store/store.dart'; import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dart'; class MobileNewTicket extends StatefulWidget { - final Key key; final int businessId; - const MobileNewTicket({this.key, int businessId}) : + const MobileNewTicket({Key? key, required int businessId}) : businessId = businessId ?? Constants.BUSINESS_ID; @override @@ -110,8 +109,8 @@ class MobileNewTicketState extends State { fontSize: 18.0 ), autofocus: true, - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).this_field_is_required; } return null; @@ -162,7 +161,7 @@ class MobileNewTicketState extends State { padding: EdgeInsets.only(top: 20.0, left: 16.0, right: 16.0, bottom: 20.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, ), child: Text( S.of(context).submit, @@ -221,8 +220,8 @@ class MobileNewTicketState extends State { } void _submit() { - final FormState form = _formKey.currentState; - if (form.validate()) { + final FormState? form = _formKey.currentState; + if (form != null && form.validate()) { setState(() { onSubmitting = true; }); @@ -331,14 +330,13 @@ class MobileNewTicketState extends State { galleryImagesFlag[imageId]['path'] = path; }); }); - return null; } ); }, ); - row.children.add(Badge( - position: BadgePosition.topEnd(top: -10.0, end: 10.0), + row.children.add(badges.Badge( + position: badges.BadgePosition.topEnd(top: -10.0, end: 10.0), badgeContent: Container( child: GestureDetector( child: Icon( @@ -374,7 +372,7 @@ class MobileNewTicketState extends State { ElevatedButton( child: Text(S.of(context).yes_i_am_sure), style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, ), onPressed: () { Navigator.of(context).pop(); diff --git a/lib/widgets/mobile/mobile_new_user.dart b/lib/widgets/mobile/mobile_new_user.dart index 1fd66a0..4f42d74 100644 --- a/lib/widgets/mobile/mobile_new_user.dart +++ b/lib/widgets/mobile/mobile_new_user.dart @@ -1,9 +1,9 @@ -import 'package:countdown/countdown.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:fluttertoast/fluttertoast.dart'; +import '../../vendor/countdown/countdown.dart'; import '../../constants.dart'; import '../../generated/l10n.dart'; import '../../routes.dart'; @@ -11,7 +11,7 @@ import '../../utils/http_util.dart'; import '../../utils/utils.dart'; class MobileNewUser extends StatefulWidget { - const MobileNewUser({Key key}) : super(key: key); + const MobileNewUser({Key? key}) : super(key: key); @override State createState() { @@ -28,9 +28,9 @@ class MobileNewUserState extends State { bool usernameEnable = true; final codeController = TextEditingController(); - bool enableGetCode; - String getCodeText; - bool canRegister; + bool enableGetCode = false; + String? getCodeText; + bool canRegister = false; var countDownListener; @@ -87,8 +87,8 @@ class MobileNewUserState extends State { fontSize: 18.0 ), autofocus: true, - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).mobile_or_email_is_required; } return null; @@ -155,7 +155,7 @@ class MobileNewUserState extends State { borderRadius: BorderRadius.all(Radius.circular(10.0)), ), child: Text( - getCodeText, + '${getCodeText}', style: TextStyle( color: enableGetCode ? Colors.black87 : Colors.black26, fontSize: 14.0 @@ -170,8 +170,8 @@ class MobileNewUserState extends State { style: TextStyle( fontSize: 18.0 ), - validator: (String value) { - if (value.trim().isEmpty) { + validator: (String? value) { + if (value == null || value.trim().isEmpty) { return S.of(context).verification_code_is_required; } return null; @@ -203,7 +203,7 @@ class MobileNewUserState extends State { alignment: Alignment.centerRight, child: ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, ), child: Text( S.of(context).register, @@ -236,8 +236,8 @@ class MobileNewUserState extends State { } void register() { - final FormState form = _formKey.currentState; - if (form.validate()) { + final FormState? form = _formKey.currentState; + if (form != null && form.validate()) { HttpUtil.httpPost('v1/users', (response) { Routes.router.navigateTo(context, '/set-password/${usernameController.text.trim()}/${codeController.text.trim()}', replace: true); }, diff --git a/lib/widgets/mobile/mobile_order_detail.dart b/lib/widgets/mobile/mobile_order_detail.dart index da9704e..c98dd8d 100644 --- a/lib/widgets/mobile/mobile_order_detail.dart +++ b/lib/widgets/mobile/mobile_order_detail.dart @@ -24,10 +24,9 @@ import '../../routes.dart'; import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dart'; class MobileOrderDetail extends StatefulWidget { - final Key key; final int orderId; final bool fromOrders; - const MobileOrderDetail(this.orderId, {this.key, this.fromOrders}); + const MobileOrderDetail(this.orderId, {Key? key, required this.fromOrders}); @override State createState() { @@ -37,18 +36,18 @@ class MobileOrderDetail extends StatefulWidget { } class MobileOrderDetailState extends State { - Order order; + Order? order; - LatLng _lastMapPosition; - LatLng customerLatLng; - LatLng deliveryLatLng; - LatLng storeLatLng; + LatLng? _lastMapPosition; + LatLng? customerLatLng; + LatLng? deliveryLatLng; + LatLng? storeLatLng; final Set _markers = {}; final Set _polyLine = {}; - BitmapDescriptor homeIcon; - BitmapDescriptor deliveryIcon; - BitmapDescriptor shopIcon; + BitmapDescriptor? homeIcon; + BitmapDescriptor? deliveryIcon; + BitmapDescriptor? shopIcon; Completer _controller = Completer(); @@ -91,15 +90,16 @@ class MobileOrderDetailState extends State { title: Text(S.of(context).order_detail), backgroundColor: Theme.of(context).primaryColor, ), - body: WillPopScope( - onWillPop: () async { - if (widget.fromOrders != null && widget.fromOrders) { - return true; + body: PopScope( + canPop: false, + onPopInvokedWithResult: (didPop, result) { + if (didPop) return; + if (widget.fromOrders) { + Navigator.of(context).pop(); } else { Routes.router.navigateTo( context, '/orders', replace: true, clearStack: true); } - return false; }, child: ListView.builder( itemCount: 4, @@ -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( @@ -142,7 +142,7 @@ class MobileOrderDetailState extends State { ), ), onTap: () { - Routes.router.navigateTo(context, '/shop/${order.businessId}/na/na/na'); + Routes.router.navigateTo(context, '/shop/${order?.businessId}/na/na/na'); }, ), ), @@ -154,7 +154,7 @@ class MobileOrderDetailState extends State { Icons.phone, ), onTap: () { - Utils.launchURL('tel:${order.businessInfo.phone}'); + Utils.launchURL('tel:${order?.businessInfo?.phone}'); }, ), ), @@ -163,15 +163,15 @@ class MobileOrderDetailState extends State { ); if (!kIsWeb) { - if (order.shippingMethod == 'store-delivery' && order.status != Constants.STATUS_COMPLETE && order.status != Constants.STATUS_CANCELLED) { + if (order!.shippingMethod == 'store-delivery' && order!.status != Constants.STATUS_COMPLETE && order!.status != Constants.STATUS_CANCELLED) { col.children.add(Container( height: 200.0, child: GoogleMap( 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, ), @@ -304,7 +304,7 @@ class MobileOrderDetailState extends State { width: 100.0, alignment: Alignment.centerRight, child: Text( - '${order.getSubtotal().toStringAsFixed(2)}', + '${order!.getSubtotal().toStringAsFixed(2)}', style: TextStyle( fontSize: 15.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, @@ -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, @@ -424,7 +424,7 @@ class MobileOrderDetailState extends State { ), ), ); - if (order.shippingMethod != 'pickup') { + if (order!.shippingMethod != 'pickup') { col.children.add(Container( child: Row( mainAxisAlignment: MainAxisAlignment.start, @@ -443,7 +443,7 @@ class MobileOrderDetailState extends State { child: Container( margin: EdgeInsets.only(top: 10.0, bottom: 10.0), child: Text( - '${order.address}, ${order.consignee}, ${order.phone}', + '${order!.address}, ${order!.consignee}, ${order!.phone}', style: TextStyle( color: Colors.black38, ), @@ -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, ), @@ -520,7 +520,7 @@ class MobileOrderDetailState extends State { margin: EdgeInsets.only(top: 10.0, bottom: 10.0), alignment: Alignment.centerRight, child: Text( - '${Utils.timestampToString(context, order.bookedAt, withTime: true)}', + '${Utils.timestampToString(context, order!.bookedAt, withTime: true)}', style: TextStyle( color: Colors.black38, ), @@ -558,7 +558,7 @@ class MobileOrderDetailState extends State { margin: EdgeInsets.only(top: 10.0, bottom: 10.0), alignment: Alignment.centerRight, child: Text( - order.shippingMethod == 'pickup' ? S.of(context).pickup : S.of(context).store_delivery, + order!.shippingMethod == 'pickup' ? S.of(context).pickup : S.of(context).store_delivery, style: TextStyle( color: Colors.black38, ), @@ -648,7 +648,7 @@ class MobileOrderDetailState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ Text( - '${order.orderNum}', + '${order!.orderNum}', style: TextStyle( color: Colors.black38, ), @@ -670,7 +670,7 @@ class MobileOrderDetailState extends State { S.of(context).copy, ), onTap: () { - Clipboard.setData(ClipboardData(text: '${order.orderNum}')); + Clipboard.setData(ClipboardData(text: '${order!.orderNum}')); Fluttertoast.showToast( msg: S.of(context).order_number_copied_to_clipboard, toastLength: Toast.LENGTH_SHORT, @@ -715,7 +715,7 @@ class MobileOrderDetailState extends State { margin: EdgeInsets.only(top: 10.0, bottom: 10.0), alignment: Alignment.centerRight, child: Text( - order.payMethod == 0 ? S.of(context).online_payment : S.of(context).pay_on_deliery, + order!.payMethod == 0 ? S.of(context).online_payment : S.of(context).pay_on_deliery, style: TextStyle( color: Colors.black38, ), @@ -756,15 +756,15 @@ class MobileOrderDetailState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ Text( - order.paymentStatus == Constants.PAYMENT_STATUS_PAID ? S.of(context).paid : S.of(context).unpaid, + order!.paymentStatus == Constants.PAYMENT_STATUS_PAID ? S.of(context).paid : S.of(context).unpaid, style: TextStyle( color: Colors.black38, ), ), Container( - margin: order.paymentStatus != Constants.PAYMENT_STATUS_PAID && order.status != Constants.STATUS_CANCELLED ? EdgeInsets.only(left: 10.0, right: 10.0) : EdgeInsets.only(left: 0.0, right: 0.0), - child: order.paymentStatus != Constants.PAYMENT_STATUS_PAID && order.status != Constants.STATUS_CANCELLED ? Text('') : SizedBox.shrink(), - decoration: order.paymentStatus != Constants.PAYMENT_STATUS_PAID && order.status != Constants.STATUS_CANCELLED ? BoxDecoration( + margin: order!.paymentStatus != Constants.PAYMENT_STATUS_PAID && order!.status != Constants.STATUS_CANCELLED ? EdgeInsets.only(left: 10.0, right: 10.0) : EdgeInsets.only(left: 0.0, right: 0.0), + child: order!.paymentStatus != Constants.PAYMENT_STATUS_PAID && order!.status != Constants.STATUS_CANCELLED ? Text('') : SizedBox.shrink(), + decoration: order!.paymentStatus != Constants.PAYMENT_STATUS_PAID && order!.status != Constants.STATUS_CANCELLED ? BoxDecoration( border: Border( left: BorderSide( width: 0.5, @@ -774,16 +774,16 @@ class MobileOrderDetailState extends State { ) : null, ), GestureDetector( - child: order.paymentStatus != Constants.PAYMENT_STATUS_PAID - && order.status != Constants.STATUS_CANCELLED - && order.status != Constants.STATUS_COMPLETE ? Text( + child: order!.paymentStatus != Constants.PAYMENT_STATUS_PAID + && order!.status != Constants.STATUS_CANCELLED + && order!.status != Constants.STATUS_COMPLETE ? Text( S.of(context).pay_now, style: TextStyle( fontWeight: FontWeight.bold, ), ) : SizedBox.shrink(), onTap: () { - Routes.router.navigateTo(context, '/paynow/${order.id}'); + Routes.router.navigateTo(context, '/paynow/${order!.id}'); }, ), ], @@ -821,7 +821,7 @@ class MobileOrderDetailState extends State { margin: EdgeInsets.only(top: 10.0, bottom: 10.0), alignment: Alignment.centerRight, child: Text( - Utils.timestampToString(context, order.createdAt, withTime: true), + Utils.timestampToString(context, order!.createdAt, withTime: true), style: TextStyle( color: Colors.black38, ), @@ -877,7 +877,7 @@ class MobileOrderDetailState extends State { ), ), Text( - Utils.getOrderStatus(context, order.status), + Utils.getOrderStatus(context, order!.status), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -899,7 +899,7 @@ class MobileOrderDetailState extends State { ), ),); - for (Fulfillment fulfillment in order.fulfillments) { + for (Fulfillment fulfillment in order!.fulfillments) { col.children.add(Container( padding: EdgeInsets.only(top: 10.0, bottom: 10.0), width: double.infinity, @@ -983,7 +983,7 @@ class MobileOrderDetailState extends State { children: [ Container( padding: EdgeInsets.only(right: 10.0), - child: order.status == Constants.STATUS_PENDING && order.paymentStatus == Constants.PAYMENT_STATUS_UNPAID ? + child: order!.status == Constants.STATUS_PENDING && order!.paymentStatus == Constants.PAYMENT_STATUS_UNPAID ? TextButton( child: Text( S.of(context).cancel_order, @@ -994,34 +994,34 @@ class MobileOrderDetailState extends State { ) : SizedBox.shrink(), ), Container( - child: order.status == Constants.STATUS_COMPLETE && !order.hasComment ? ElevatedButton( + child: order!.status == Constants.STATUS_COMPLETE && !order!.hasComment ? ElevatedButton( child: Text( S.of(context).comment, ), onPressed: () { - Routes.router.navigateTo(context, '/new-comment/${order.id}'); + Routes.router.navigateTo(context, '/new-comment/${order!.id}'); }, ) : SizedBox.shrink(), ), ], ), Container( - child: order.paymentStatus != Constants.PAYMENT_STATUS_PAID - && order.status != Constants.STATUS_CANCELLED - && order.status != Constants.STATUS_COMPLETE ? + child: order!.paymentStatus != Constants.PAYMENT_STATUS_PAID + && order!.status != Constants.STATUS_CANCELLED + && order!.status != Constants.STATUS_COMPLETE ? TextButton( child: Text( S.of(context).pay_now, ), onPressed: () { - Routes.router.navigateTo(context, '/paynow/${order.id}'); + Routes.router.navigateTo(context, '/paynow/${order!.id}'); }, ) : TextButton( child: Text( S.of(context).order_again, ), onPressed: () { - Utils.orderAgain(context, order.cartInfo); + Utils.orderAgain(context, order!.cartInfo!); }, ), ), @@ -1059,13 +1059,13 @@ class MobileOrderDetailState extends State { order = Order.fromJson(data); 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)); + if (order!.shippingMethod == 'store-delivery' && order!.status != Constants.STATUS_COMPLETE && order!.status != Constants.STATUS_CANCELLED) { + storeLatLng = LatLng(double.parse(order!.businessInfo?.address.lat ?? '0'), + double.parse(order!.businessInfo?.address.lng ?? '0')); + customerLatLng = LatLng(double.parse(order!.shippingAddress?.lat ?? '0'), + double.parse(order!.shippingAddress?.lng ?? '0')); deliveryLatLng = - LatLng(order.shipperPosition.lat, order.shipperPosition.lng); + LatLng(order!.shipperPosition.lat, order!.shipperPosition.lng); _polyLine.clear(); _polyLine.add( @@ -1078,8 +1078,8 @@ class MobileOrderDetailState extends State { ], width: 3, points: [ - order.shipperPosition.lat != 0.0 ? deliveryLatLng : storeLatLng, - customerLatLng, + order!.shipperPosition.lat != 0.0 ? deliveryLatLng! : storeLatLng!, + customerLatLng!, ] ) ); @@ -1087,38 +1087,38 @@ class MobileOrderDetailState extends State { _markers.clear(); _markers.add(Marker( markerId: MarkerId('shop_position'), - position: storeLatLng, + position: storeLatLng!, infoWindow: InfoWindow( title: S .of(context) .store, snippet: '', ), - icon: shopIcon, + icon: shopIcon!, )); _markers.add(Marker( markerId: MarkerId('customer_position'), - position: customerLatLng, + position: customerLatLng!, infoWindow: InfoWindow( title: S .of(context) .customer, - snippet: order.shippingAddress.addressLine1, + snippet: order!.shippingAddress!.addressLine1, ), - icon: homeIcon, + 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, + position: deliveryLatLng!, infoWindow: InfoWindow( title: S .of(context) .delivery_guy, snippet: '', ), - icon: deliveryIcon, + icon: deliveryIcon!, )); } } @@ -1145,7 +1145,7 @@ class MobileOrderDetailState extends State { S.of(context).no, ), style: TextButton.styleFrom( - primary: Theme.of(context).primaryColor, + foregroundColor: Theme.of(context).primaryColor, ), onPressed: () { Navigator.of(context).pop(); diff --git a/lib/widgets/mobile/mobile_orders.dart b/lib/widgets/mobile/mobile_orders.dart index 66d077a..000b087 100644 --- a/lib/widgets/mobile/mobile_orders.dart +++ b/lib/widgets/mobile/mobile_orders.dart @@ -18,8 +18,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'MobileBottomNav.dart'; class MobileOrders extends StatefulWidget { - final Key key; - const MobileOrders({this.key}); + const MobileOrders({Key? key}); @override State createState() { @@ -31,7 +30,7 @@ class MobileOrders extends StatefulWidget { class MobileOrdersState extends State with SingleTickerProviderStateMixin { GlobalKey _scaffoldKey = GlobalKey(); - List orders = []; + List? orders = []; int _page = 1; int _pageCount = 1; @@ -44,7 +43,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta void _onRefresh() { _page = 1; if (orders != null) { - orders.clear(); + orders?.clear(); } else { orders = []; } @@ -79,7 +78,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta enablePullUp: true, header: WaterDropHeader(), footer: CustomFooter( - builder: (BuildContext context, LoadStatus mode){ + builder: (BuildContext context, LoadStatus? mode){ Widget footer; if(mode == LoadStatus.idle) { footer = Text(S.of(context).pull_up_to_load_more); @@ -127,11 +126,11 @@ class MobileOrdersState extends State with SingleTickerProviderSta Widget _buildBody() { return ListView.builder( - itemCount: orders != null && orders.length > 0 ? orders.length : 1, + itemCount: orders != null && orders!.length > 0 ? orders!.length : 1, itemBuilder: (BuildContext context, int position) { - Order order; - if (orders != null && orders.length > 0) { - order = orders[position]; + Order? order; + if (orders != null && orders!.length > 0) { + order = orders![position]; } if (order == null) { return Container( @@ -152,7 +151,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,10 +160,10 @@ 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)), + S.of(context).and_more_item_token(Utils.getProductLineInOrder(order.cartInfo!)), style: TextStyle( fontSize: 12.0, color: Colors.black26, @@ -193,7 +192,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta ), onPressed: () { Navigator.push(context, MaterialPageRoute( - builder: (BuildContext context) => OrderDetail(order.id, fromOrders: true,), + builder: (BuildContext context) => OrderDetail(order!.id, fromOrders: true,), )); }, ), @@ -208,7 +207,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta S.of(context).comment, ), onPressed: () { - Routes.router.navigateTo(context, '/new-comment/${order.id}'); + Routes.router.navigateTo(context, '/new-comment/${order!.id}'); }, ), ), @@ -234,10 +233,10 @@ class MobileOrdersState extends State with SingleTickerProviderSta ), ), style: ElevatedButton.styleFrom( - primary: Colors.redAccent, + backgroundColor: Colors.redAccent, ), onPressed: () { - Routes.router.navigateTo(context, '/paynow/${order.id}'); + Routes.router.navigateTo(context, '/paynow/${order!.id}'); }, )); } else { @@ -249,10 +248,10 @@ class MobileOrdersState extends State with SingleTickerProviderSta ), ), style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, ), onPressed: () { - Utils.orderAgain(context, order.cartInfo); + Utils.orderAgain(context, order!.cartInfo!); }, )); } @@ -266,10 +265,10 @@ class MobileOrdersState extends State with SingleTickerProviderSta ), ), style: ElevatedButton.styleFrom( - primary: Theme.of(context).primaryColor, + backgroundColor: Theme.of(context).primaryColor, ), onPressed: () { - Utils.orderAgain(context, order.cartInfo); + Utils.orderAgain(context, order!.cartInfo!); }, )); } @@ -291,7 +290,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 +306,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta children: [ Container( child: Text( - '${order.cartInfo.businessInfo.name}', + '${order.cartInfo!.businessInfo?.name}', style: TextStyle( fontSize: 20.0, ), @@ -329,7 +328,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta ), onTap: () { Navigator.push(context, MaterialPageRoute( - builder: (BuildContext context) => OrderDetail(order.id, fromOrders: true,), + builder: (BuildContext context) => OrderDetail(order!.id, fromOrders: true,), )); }, ), @@ -375,7 +374,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta ), onTap: () { Navigator.push(context, MaterialPageRoute( - builder: (BuildContext context) => OrderDetail(order.id, fromOrders: true,), + builder: (BuildContext context) => OrderDetail(order!.id, fromOrders: true,), )); }, ), @@ -438,7 +437,7 @@ class MobileOrdersState extends State with SingleTickerProviderSta if (mounted) { setState(() { _isLoading = false; - orders.addAll((data['items'] as List).map((e) => Order.fromJson(e)).toList()); + orders!.addAll((data['items'] as List).map((e) => Order.fromJson(e)).toList()); }); } }).catchError((error) { diff --git a/lib/widgets/mobile/mobile_pay_now.dart b/lib/widgets/mobile/mobile_pay_now.dart index 5428d14..b00c0f4 100644 --- a/lib/widgets/mobile/mobile_pay_now.dart +++ b/lib/widgets/mobile/mobile_pay_now.dart @@ -20,9 +20,8 @@ import '../../utils/utils.dart'; import '../../widgets/general/payment_verification_code_dialog.dart'; class MobilePayNow extends StatefulWidget { - final Key key; final int orderId; - const MobilePayNow(this.orderId, {this.key}); + const MobilePayNow(this.orderId, {Key? key}); @override State createState() { @@ -32,11 +31,11 @@ class MobilePayNow extends StatefulWidget { } class MobilePayNowState extends State { - Order order; - List paymentPlatforms; - User _user; + Order? order; + List? paymentPlatforms; + User? _user; - bool nativePay; + bool nativePay = false; @override Widget build(BuildContext context) { @@ -56,7 +55,7 @@ class MobilePayNowState extends State { BuildContext mainContext = context; ListView listView = ListView.builder( - itemCount: nativePay ? paymentPlatforms.length + 3 : paymentPlatforms.length + 2, + itemCount: nativePay ? paymentPlatforms!.length + 3 : paymentPlatforms!.length + 2, itemBuilder: (BuildContext context, int position) { if (position == 0) { return Column( @@ -77,7 +76,7 @@ class MobilePayNowState extends State { ), ), Text( - '\$${order.totalPrice.toStringAsFixed(2)}', + '\$${order!.totalPrice.toStringAsFixed(2)}', style: TextStyle( fontSize: 24.0, fontWeight: FontWeight.bold, @@ -94,7 +93,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), @@ -157,8 +156,8 @@ class MobilePayNowState extends State { } PaymentPlatform paymentPlatform; if (position == 1) { - if (_user.stripePaymentMethods.length > 0) { - paymentPlatform = paymentPlatforms[position - 1]; + if (_user!.stripePaymentMethods.length > 0) { + paymentPlatform = paymentPlatforms![position - 1]; Column column = Column( children: [], ); @@ -180,7 +179,7 @@ class MobilePayNowState extends State { ), ), ); - for (StripePaymentMethod stripePaymentMethod in _user.stripePaymentMethods) { + for (StripePaymentMethod stripePaymentMethod in _user!.stripePaymentMethods) { column.children.add( GestureDetector( child: Container( @@ -249,8 +248,8 @@ class MobilePayNowState extends State { showDialog( context: mainContext, builder: (BuildContext context) { - return PaymentVerificationCodeDialog(_user, () { - Util.goPayment(context, order, paymentPlatform, + return PaymentVerificationCodeDialog(_user!, () { + Util.goPayment(context, order!, paymentPlatform, stripePaymentMethod: stripePaymentMethod); }, () { @@ -281,10 +280,10 @@ class MobilePayNowState extends State { } } if (position == 2 && nativePay) { - paymentPlatform = paymentPlatforms[position - 2]; - return Util().getNativePay(mainContext, order, paymentPlatform); + paymentPlatform = paymentPlatforms![position - 2]; + return Util().getNativePay(mainContext, order!, paymentPlatform); } - paymentPlatform = nativePay ? paymentPlatforms[position - 3] : paymentPlatforms[position - 2]; + paymentPlatform = nativePay ? paymentPlatforms![position - 3] : paymentPlatforms![position - 2]; return GestureDetector( child: Container( padding: EdgeInsets.only(top: 16.0, left: 16.0, right: 16.0, bottom: 16.0), @@ -293,7 +292,7 @@ class MobilePayNowState extends State { children: [ Container( padding: EdgeInsets.only(right: 10.0), - child: Util.showImage(paymentPlatform.icon, + child: Util.showImage(paymentPlatform.icon ?? '', errorWidget: (context, url, error) => Icon(Icons.broken_image, size: 50.0, color: Colors.transparent,), fit: BoxFit.cover, width: 50.0, @@ -302,7 +301,7 @@ class MobilePayNowState extends State { ), Expanded( child: Text( - S.of(context).pay_with_token(PaymentPlatform.getPaymentPlatformName(context, paymentPlatform.code)), + S.of(context).pay_with_token(PaymentPlatform.getPaymentPlatformName(context, paymentPlatform.code ?? '')), style: TextStyle( fontSize: 18.0, fontWeight: FontWeight.bold, @@ -325,7 +324,7 @@ class MobilePayNowState extends State { ), ), onTap: () { - Util.goPayment(context, order, paymentPlatform); + Util.goPayment(context, order!, paymentPlatform); }, ); } @@ -354,10 +353,10 @@ class MobilePayNowState extends State { ).then((data) { paymentPlatforms = (data['payment_platforms'] as List).map((e) => PaymentPlatform.fromJson(e)).toList(); - PaymentPlatform pp = paymentPlatforms[0]; + PaymentPlatform pp = paymentPlatforms![0]; if (Constants.ENABLE_NATIVE_PAY && pp.publishableKey != null - && pp.publishableKey.isNotEmpty && pp.merchantId != null - && pp.merchantId.isNotEmpty) { + && pp.publishableKey!.isNotEmpty && pp.merchantId != null + && pp.merchantId!.isNotEmpty) { nativePay = true; } else { nativePay = false; diff --git a/lib/widgets/mobile/mobile_stripe_pay_web.dart b/lib/widgets/mobile/mobile_stripe_pay_web.dart index a6c80a6..ad79a1d 100644 --- a/lib/widgets/mobile/mobile_stripe_pay_web.dart +++ b/lib/widgets/mobile/mobile_stripe_pay_web.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:stripe_sdk/stripe_sdk.dart'; -import 'package:stripe_sdk/stripe_sdk_ui.dart'; +import '../../vendor/stripe_sdk/lib/stripe_sdk_ui.dart'; +import '../../utils/mini_stripe_api.dart'; import '../../constants.dart'; import '../../events/eventbus.dart'; @@ -18,11 +18,10 @@ import '../../utils/utils.dart'; class MobileStripePayWeb extends StatefulWidget { - final Key key; final Order order; final PaymentPlatform paymentPlatform; - final StripePaymentMethod stripePaymentMethod; - const MobileStripePayWeb(this.order, this.paymentPlatform, {this.key, this.stripePaymentMethod}); + final StripePaymentMethod? stripePaymentMethod; + const MobileStripePayWeb(this.order, this.paymentPlatform, {Key? key, this.stripePaymentMethod}); @override State createState() { @@ -37,9 +36,9 @@ class MobileStripePayWebState extends State { final formKey = GlobalKey(); final card = StripeCard(); - CardForm form; + CardForm? form; - bool isSubmitting; + bool isSubmitting = false; @override Widget build(BuildContext context) { @@ -55,7 +54,7 @@ class MobileStripePayWebState extends State { if (widget.stripePaymentMethod == null) { form = CardForm(card: card, formKey: formKey, displayPostalCode: false,); body = ListView( - children: [form,], + children: [form!,], ); } @@ -80,8 +79,8 @@ class MobileStripePayWebState extends State { IconButton( icon: Icon(Icons.check), onPressed: widget.stripePaymentMethod == null ? () { - if (formKey.currentState.validate()) { - formKey.currentState.save(); + if (formKey.currentState != null && formKey.currentState!.validate()) { + formKey.currentState!.save(); _paymentRequestWithCard(context); } else { ScaffoldMessenger.of(context).showSnackBar( @@ -102,7 +101,7 @@ class MobileStripePayWebState extends State { void initState() { super.initState(); isSubmitting = false; - StripeApi.init(widget.paymentPlatform.publishableKey); + MiniStripeApi.init(widget.paymentPlatform.publishableKey!); } SnackBar messageSnackBar(BuildContext context, String message) { @@ -131,12 +130,12 @@ class MobileStripePayWebState extends State { } _paymentWithPaymentMethod(BuildContext context) async { - Utils.stripePaymentIntent(widget.order, widget.stripePaymentMethod.customerId, - widget.stripePaymentMethod.paymentMethodId, - widget.stripePaymentMethod.paymentMethodType, (response) async { + Utils.stripePaymentIntent(widget.order, widget.stripePaymentMethod?.customerId, + widget.stripePaymentMethod!.paymentMethodId, + widget.stripePaymentMethod!.paymentMethodType, (response) async { if (response.data['status'] == Constants.STRIPE_STATUS_REQUIRES_CONFIRMATION) { - await StripeApi.instance.confirmPaymentIntent( + await MiniStripeApi.instance.confirmPaymentIntent( response.data[Constants.STRIPE_CLIENT_SECRET], data: { 'payment_method': response.data['payment_method'], @@ -144,7 +143,7 @@ class MobileStripePayWebState extends State { ).then((result2) { if (result2['status'] == Constants.STRIPE_STATUS_SUCCEDED) { Utils.stripeChargedSuccess(widget.order, - widget.stripePaymentMethod.paymentMethodId, + widget.stripePaymentMethod!.paymentMethodId, result2['id'], (response) { if (isSubmitting) { Navigator.of(context).pop(); @@ -169,11 +168,11 @@ class MobileStripePayWebState extends State { _paymentRequestWithCard(BuildContext context) async { isSubmitting = true; Utils.showSubmitDialog(context); - await StripeApi.instance.createPaymentMethodFromCard(card) + await MiniStripeApi.instance.createPaymentMethodFromCard(card) .then((result) { Utils.stripePaymentIntent(widget.order, null, result['id'], result['type'], (response) async { if (response.data['status'] == Constants.STRIPE_STATUS_REQUIRES_CONFIRMATION) { - await StripeApi.instance.confirmPaymentIntent( + await MiniStripeApi.instance.confirmPaymentIntent( response.data[Constants.STRIPE_CLIENT_SECRET], data: { 'payment_method': response.data['payment_method'], diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 5a2da2c..7299b5c 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,13 +6,13 @@ #include "generated_plugin_registrant.h" -#include +#include #include void fl_register_plugins(FlPluginRegistry* registry) { - g_autoptr(FlPluginRegistrar) catcher_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "CatcherPlugin"); - catcher_plugin_register_with_registrar(catcher_registrar); + g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); + file_selector_plugin_register_with_registrar(file_selector_linux_registrar); g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index faffff3..786ff5c 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,7 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST - catcher + file_selector_linux url_launcher_linux ) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 94f1d6f..0601f8c 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,20 +5,16 @@ import FlutterMacOS import Foundation -import catcher -import device_info_plus_macos -import flutter_local_notifications -import package_info_plus_macos -import path_provider_macos -import sqflite +import file_selector_macos +import path_provider_foundation +import shared_preferences_foundation +import sqflite_darwin import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - CatcherPlugin.register(with: registry.registrar(forPlugin: "CatcherPlugin")) - DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) - FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) - FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) + FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 4c98351..8bea54a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,341 +5,332 @@ packages: dependency: transitive description: name: archive - url: "https://pub.dartlang.org" + sha256: a96e8b390886ee8abb49b7bd3ac8df6f451c621619f52a26e815fdcf568959ff + url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "4.0.9" args: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.7.0" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: db4766341bd8ecb66556f31ab891a5d596ef829221993531bd64a8e6342f0cda + url: "https://pub.dev" source: hosted version: "2.8.2" - awesome_card: - dependency: transitive - description: - name: awesome_card - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.7" badges: dependency: "direct main" description: name: badges - url: "https://pub.dartlang.org" + sha256: a7b6bbd60dce418df0db3058b53f9d083c22cdb5132a052145dc267494df0b84 + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.1.2" cached_network_image: dependency: "direct main" description: name: cached_network_image - url: "https://pub.dartlang.org" + sha256: "28ea9690a8207179c319965c13cd8df184d5ee721ae2ce60f398ced1219cea1f" + url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.3.1" cached_network_image_platform_interface: dependency: transitive description: name: cached_network_image_platform_interface - url: "https://pub.dartlang.org" + sha256: "9e90e78ae72caa874a323d78fa6301b3fb8fa7ea76a8f96dc5b5bf79f283bf2f" + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "4.0.0" cached_network_image_web: dependency: transitive description: name: cached_network_image_web - url: "https://pub.dartlang.org" + sha256: "205d6a9f1862de34b93184f22b9d2d94586b2f05c581d546695e3d8f6a805cd7" + url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "1.2.0" carousel_slider: dependency: "direct main" description: name: carousel_slider - url: "https://pub.dartlang.org" + sha256: febf4b0163e0242adc13d7a863b04965351f59e7dfea56675c7c2caa7bcd7476 + url: "https://pub.dev" source: hosted - version: "4.0.0" - catcher: - dependency: "direct main" - description: - name: catcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.8" + version: "5.1.2" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.4.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" source: hosted version: "1.3.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c + url: "https://pub.dev" + source: hosted + version: "0.4.2" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.2" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" source: hosted - version: "1.16.0" - countdown: - dependency: "direct main" - description: - name: countdown - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.0" - credit_card_type_detector: - dependency: transitive - description: - name: credit_card_type_detector - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - credit_card_validator: - dependency: transitive - description: - name: credit_card_validator - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" + version: "1.19.1" cross_file: dependency: transitive description: name: cross_file - url: "https://pub.dartlang.org" + sha256: "437b2b8da454fe1e01131f4410274fd607347325e9330f0b469ed5a204991068" + url: "https://pub.dev" source: hosted version: "0.3.1+4" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: cf75650c66c0316274e21d7c43d3dea246273af5955bd94e8184837cd577575c + url: "https://pub.dev" source: hosted version: "3.0.1" csslib: dependency: transitive description: name: csslib - url: "https://pub.dartlang.org" + sha256: f857285c8dc0b4f2f77b49a1c083ff8c75223a7549de20f3e607df58cf497a43 + url: "https://pub.dev" source: hosted version: "0.17.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" source: hosted - version: "1.0.3" - device_info_plus: - dependency: transitive - description: - name: device_info_plus - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - device_info_plus_linux: - dependency: transitive - description: - name: device_info_plus_linux - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - device_info_plus_macos: - dependency: transitive - description: - name: device_info_plus_macos - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - device_info_plus_platform_interface: - dependency: transitive - description: - name: device_info_plus_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - device_info_plus_web: - dependency: transitive - description: - name: device_info_plus_web - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - device_info_plus_windows: - dependency: transitive - description: - name: device_info_plus_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" + version: "1.0.8" dio: dependency: "direct main" description: name: dio - url: "https://pub.dartlang.org" + sha256: aff32c08f92787a557dd5c0145ac91536481831a01b4648136373cddb0e64f8c + url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "5.9.2" + dio_web_adapter: + dependency: transitive + description: + name: dio_web_adapter + sha256: "2f9e64323a7c3c7ef69567d5c800424a11f8337b8b228bad02524c9fb3c1f340" + url: "https://pub.dev" + source: hosted + version: "2.1.2" email_validator: dependency: "direct main" description: name: email_validator - url: "https://pub.dartlang.org" + sha256: e9a90f27ab2b915a27d7f9c2a7ddda5dd752d6942616ee83529b686fc086221b + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.17" event_bus: dependency: "direct main" description: name: event_bus - url: "https://pub.dartlang.org" + sha256: "44baa799834f4c803921873e7446a2add0f3efa45e101a054b1f0ab9b95f8edc" + url: "https://pub.dev" source: hosted version: "2.0.0" ffi: dependency: "direct main" description: name: ffi - url: "https://pub.dartlang.org" + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" + url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "2.2.0" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" source: hosted - version: "6.1.2" - flappy_search_bar: - dependency: "direct main" + version: "6.1.4" + file_selector_linux: + dependency: transitive description: - name: flappy_search_bar - url: "https://pub.dartlang.org" + name: file_selector_linux + sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33" + url: "https://pub.dev" source: hosted - version: "1.7.2" + version: "0.9.3+2" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + sha256: "19124ff4a3d8864fdc62072b6a2ef6c222d55a3404fe14893a3c02744907b60c" + url: "https://pub.dev" + source: hosted + version: "0.9.4+4" + file_selector_platform_interface: + dependency: transitive + description: + name: file_selector_platform_interface + sha256: "35e0bd61ebcdb91a3505813b055b09b79dfdc7d0aee9c09a7ba59ae4bb13dc85" + url: "https://pub.dev" + source: hosted + version: "2.7.0" + file_selector_windows: + dependency: transitive + description: + name: file_selector_windows + sha256: "320fcfb6f33caa90f0b58380489fc5ac05d99ee94b61aa96ec2bff0ba81d3c2b" + url: "https://pub.dev" + source: hosted + version: "0.9.3+4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" fluro: dependency: "direct main" description: name: fluro - url: "https://pub.dartlang.org" + sha256: "24d07d0b285b213ec2045b83e85d076185fa5c23651e44dae0ac6755784b97d0" + url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "2.0.5" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" - flutter_blurhash: - dependency: transitive - description: - name: flutter_blurhash - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.0" flutter_cache_manager: dependency: transitive description: name: flutter_cache_manager - url: "https://pub.dartlang.org" + sha256: "8207f27539deb83732fdda03e259349046a39a4c767269285f449ade355d54ba" + url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.3.1" flutter_dash: dependency: "direct main" description: name: flutter_dash - url: "https://pub.dartlang.org" + sha256: dc282109cc12806853e102a4e8b9d99abb7f527fcedec2ea03860e2500ee6622 + url: "https://pub.dev" source: hosted - version: "0.0.1" + version: "1.0.0" flutter_inappwebview: dependency: "direct main" description: name: flutter_inappwebview - url: "https://pub.dartlang.org" + sha256: "5cfdfe79aaf4753626d1e46772c9d7feee74e5cff66da000e098c29b9a8d61e1" + url: "https://pub.dev" source: hosted version: "5.3.2" flutter_launcher_icons: dependency: "direct main" description: name: flutter_launcher_icons - url: "https://pub.dartlang.org" + sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea" + url: "https://pub.dev" source: hosted - version: "0.9.1" - flutter_local_notifications: - dependency: "direct main" - description: - name: flutter_local_notifications - url: "https://pub.dartlang.org" - source: hosted - version: "8.1.1" - flutter_local_notifications_platform_interface: - dependency: transitive - description: - name: flutter_local_notifications_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.1" + version: "0.13.1" flutter_localizations: dependency: "direct main" description: flutter source: sdk version: "0.0.0" - flutter_mailer: - dependency: transitive - description: - name: flutter_mailer - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" flutter_markdown: dependency: "direct main" description: name: flutter_markdown - url: "https://pub.dartlang.org" + sha256: "08fb8315236099ff8e90cb87bb2b935e0a724a3af1623000a9cec930468e0f27" + url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.7.7+1" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle - url: "https://pub.dartlang.org" + sha256: aa36b33c721ac6e889adad07e3c87e6a07b33c28d1f2bc22f2561762cd7d2162 + url: "https://pub.dev" source: hosted version: "2.0.2" flutter_redux: dependency: "direct main" description: name: flutter_redux - url: "https://pub.dartlang.org" + sha256: "3b20be9e08d0038e1452fbfa1fdb1ea0a7c3738c997734530b3c6d0bb5fcdbdc" + url: "https://pub.dev" source: hosted - version: "0.8.2" + version: "0.10.0" + flutter_searchable_dropdown: + dependency: "direct main" + description: + name: flutter_searchable_dropdown + sha256: "884548ae38c1388da4952c0a9ffbff5960ab7bc2544e1e2a3065df3f8ebf3872" + url: "https://pub.dev" + source: hosted + version: "2.0.0" flutter_spinkit: dependency: "direct main" description: name: flutter_spinkit - url: "https://pub.dartlang.org" + sha256: "77850df57c00dc218bfe96071d576a8babec24cf58b2ed121c83cca4a2fdce7f" + url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.2.2" flutter_staggered_grid_view: - dependency: transitive + dependency: "direct main" description: name: flutter_staggered_grid_view - url: "https://pub.dartlang.org" + sha256: f0b6d8c0fa7b4b444985cdde68492c0138a4fb6fc57a641b24cb234b7ee0f5c4 + url: "https://pub.dev" source: hosted - version: "0.3.4" + version: "0.4.1" flutter_web_plugins: dependency: "direct main" description: flutter @@ -349,688 +340,783 @@ packages: dependency: "direct main" description: name: fluttertoast - url: "https://pub.dartlang.org" + sha256: b3ae793108ad2a7e8f2fea91ca5bb2ba7ef03621c4d9ed7a92fe3391da64c000 + url: "https://pub.dev" source: hosted version: "8.0.8" - font_awesome_flutter: + gender_picker: dependency: "direct main" description: - name: font_awesome_flutter - url: "https://pub.dartlang.org" + name: gender_picker + sha256: "75180516208bb524ba6164755915edefaff8035cbfbc94073427270c4b1b766c" + url: "https://pub.dev" source: hosted - version: "9.1.0" - gender_selection: - dependency: "direct main" - description: - name: gender_selection - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" + version: "1.1.0" geolocator: dependency: "direct main" description: name: geolocator - url: "https://pub.dartlang.org" + sha256: "712f596f5b14a8cb8873963978c0b48ce9abf8228fe6d60f9a837e2e2485fe30" + url: "https://pub.dev" source: hosted version: "7.4.0" geolocator_android: dependency: transitive description: name: geolocator_android - url: "https://pub.dartlang.org" + sha256: "41a749656e0a43de3c0c1b7a8e21ae4aca56b4b7890f7aafc61d1651c131a575" + url: "https://pub.dev" source: hosted version: "1.0.0" geolocator_apple: dependency: transitive description: name: geolocator_apple - url: "https://pub.dartlang.org" + sha256: "651b2a2cfd45ea7d7b06288f8fc542a0e4056a75136ea3da94f70237cafccb7b" + url: "https://pub.dev" source: hosted version: "1.0.0" geolocator_platform_interface: dependency: transitive description: name: geolocator_platform_interface - url: "https://pub.dartlang.org" + sha256: "92435fd51445cd12105f4fa8edb6ebbaf4401331e70fad9cd39e6400671de916" + url: "https://pub.dev" source: hosted version: "2.3.2" geolocator_web: dependency: transitive description: name: geolocator_web - url: "https://pub.dartlang.org" + sha256: "0b9e0ec13ce2211085cae0055b3516c975bd6cfe2878a20c8f13611f1a259855" + url: "https://pub.dev" source: hosted version: "2.0.6" + google_maps: + dependency: transitive + description: + name: google_maps + sha256: "5d410c32112d7c6eb7858d359275b2aa04778eed3e36c745aeae905fb2fa6468" + url: "https://pub.dev" + source: hosted + version: "8.2.0" google_maps_flutter: dependency: "direct main" description: name: google_maps_flutter - url: "https://pub.dartlang.org" + sha256: "819985697596a42e1054b5feb2f407ba1ac92262e02844a40168e742b9f36dca" + url: "https://pub.dev" source: hosted - version: "2.0.6" + version: "2.14.0" + google_maps_flutter_android: + dependency: transitive + description: + name: google_maps_flutter_android + sha256: "7c7ff5b883b27bfdd0d52d91d89faf00858a6c1b33aeca0dc80faca64f389983" + url: "https://pub.dev" + source: hosted + version: "2.18.3" + google_maps_flutter_ios: + dependency: transitive + description: + name: google_maps_flutter_ios + sha256: ca02463b19a9abc7d31fcaf22631d021d647107467f741b917a69fa26659fd75 + url: "https://pub.dev" + source: hosted + version: "2.15.5" google_maps_flutter_platform_interface: dependency: transitive description: name: google_maps_flutter_platform_interface - url: "https://pub.dartlang.org" + sha256: f4b9b44f7b12a1f6707ffc79d082738e0b7e194bf728ee61d2b3cdf5fdf16081 + url: "https://pub.dev" source: hosted - version: "2.1.0" - hive: - dependency: "direct main" + version: "2.14.0" + google_maps_flutter_web: + dependency: transitive description: - name: hive - url: "https://pub.dartlang.org" + name: google_maps_flutter_web + sha256: d416602944e1859f3cbbaa53e34785c223fa0a11eddb34a913c964c5cbb5d8cf + url: "https://pub.dev" source: hosted - version: "2.0.4" - hive_flutter: - dependency: "direct main" - description: - name: hive_flutter - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" + version: "0.5.14+3" hovering: dependency: "direct main" description: name: hovering - url: "https://pub.dartlang.org" + sha256: "0df77800487be6d29c8687fb775f53e1b308988c6e63a6a9c579cec701fbfe76" + url: "https://pub.dev" source: hosted version: "1.0.4" html: dependency: transitive description: name: html - url: "https://pub.dartlang.org" + sha256: bfef906cbd4e78ef49ae511d9074aebd1d2251482ef601a280973e8b58b51bbf + url: "https://pub.dev" source: hosted version: "0.15.0" http: dependency: transitive description: name: http - url: "https://pub.dartlang.org" + sha256: "2ed163531e071c2c6b7c659635112f24cb64ecbebf6af46b550d536c0b1aa112" + url: "https://pub.dev" source: hosted version: "0.13.4" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: e362d639ba3bc07d5a71faebb98cde68c05bfbcfbbb444b60b6f60bb67719185 + url: "https://pub.dev" source: hosted version: "4.0.0" image: dependency: transitive description: name: image - url: "https://pub.dartlang.org" + sha256: f9881ff4998044947ec38d098bc7c8316ae1186fa786eddffdb867b9bc94dfce + url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "4.8.0" image_picker: dependency: "direct main" description: name: image_picker - url: "https://pub.dartlang.org" + sha256: b6951e25b795d053a6ba03af5f710069c99349de9341af95155d52665cb4607c + url: "https://pub.dev" source: hosted - version: "0.8.3+1" + version: "0.8.9" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + sha256: "28f3987ca0ec702d346eae1d90eda59603a2101b52f1e234ded62cff1d5cfa6e" + url: "https://pub.dev" + source: hosted + version: "0.8.13+1" image_picker_for_web: dependency: transitive description: name: image_picker_for_web - url: "https://pub.dartlang.org" + sha256: "8c3ea4a41dc8fe161845a490b5d1b29b73a81f5dd694cbc28b469daf175fe4cd" + url: "https://pub.dev" source: hosted version: "2.1.2" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + sha256: eb06fe30bab4c4497bad449b66448f50edcc695f1c59408e78aa3a8059eb8f0e + url: "https://pub.dev" + source: hosted + version: "0.8.13" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + sha256: "1f81c5f2046b9ab724f85523e4af65be1d47b038160a8c8deed909762c308ed4" + url: "https://pub.dev" + source: hosted + version: "0.2.2" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + sha256: d58cd9d67793d52beefd6585b12050af0a7663c0c2a6ece0fb110a35d6955e04 + url: "https://pub.dev" + source: hosted + version: "0.2.2" image_picker_platform_interface: dependency: transitive description: name: image_picker_platform_interface - url: "https://pub.dartlang.org" + sha256: "567e056716333a1647c64bb6bd873cff7622233a5c3f694be28a583d4715690c" + url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.11.1" + image_picker_windows: + dependency: transitive + description: + name: image_picker_windows + sha256: d248c86554a72b5495a31c56f060cf73a41c7ff541689327b1a7dbccc33adfae + url: "https://pub.dev" + source: hosted + version: "0.2.2" intl: dependency: transitive description: name: intl - url: "https://pub.dartlang.org" + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" source: hosted - version: "0.17.0" - js: + version: "0.19.0" + json_annotation: dependency: transitive description: - name: js - url: "https://pub.dartlang.org" + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" source: hosted - version: "0.6.4" - logging: - dependency: transitive - description: - name: logging - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" - mailer: - dependency: transitive - description: - name: mailer - url: "https://pub.dartlang.org" - source: hosted - version: "5.0.1" + version: "4.9.0" markdown: dependency: transitive description: name: markdown - url: "https://pub.dartlang.org" + sha256: "935e23e1ff3bc02d390bad4d4be001208ee92cc217cb5b5a6c19bc14aaa318c1" + url: "https://pub.dev" source: hosted - version: "4.0.0" - mask_text_input_formatter: - dependency: transitive - description: - name: mask_text_input_formatter - url: "https://pub.dartlang.org" - source: hosted - version: "2.3.0" + version: "7.3.0" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.11.1" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.16.0" mime: dependency: transitive description: name: mime - url: "https://pub.dartlang.org" + sha256: a7a98ea7f366e2cc9d2b20873815aebec5e2bc124fe0da9d3f7f59b0625ea180 + url: "https://pub.dev" + source: hosted + version: "1.0.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" source: hosted version: "1.0.0" octo_image: dependency: transitive description: name: octo_image - url: "https://pub.dartlang.org" + sha256: "34faa6639a78c7e3cbe79be6f9f96535867e879748ade7d17c9b1ae7536293bd" + url: "https://pub.dev" source: hosted - version: "1.0.0+1" - package_info_plus: - dependency: transitive - description: - name: package_info_plus - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.4" - package_info_plus_linux: - dependency: transitive - description: - name: package_info_plus_linux - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" - package_info_plus_macos: - dependency: transitive - description: - name: package_info_plus_macos - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - package_info_plus_platform_interface: - dependency: transitive - description: - name: package_info_plus_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.2" - package_info_plus_web: - dependency: transitive - description: - name: package_info_plus_web - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" - package_info_plus_windows: - dependency: transitive - description: - name: package_info_plus_windows - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" + version: "2.1.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.9.1" path_provider: dependency: "direct main" description: name: path_provider - url: "https://pub.dartlang.org" + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.1.5" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "3b4c1fc3aa55ddc9cd4aa6759984330d5c8e66aa7702a6223c61540dc6380c37" + url: "https://pub.dev" + source: hosted + version: "2.2.19" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "16eef174aacb07e09c351502740fa6254c165757638eba1e9116b0a781201bbd" + url: "https://pub.dev" + source: hosted + version: "2.4.2" path_provider_linux: dependency: transitive description: name: path_provider_linux - url: "https://pub.dartlang.org" + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" source: hosted - version: "2.0.2" - path_provider_macos: - dependency: transitive - description: - name: path_provider_macos - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" + version: "2.2.1" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - url: "https://pub.dartlang.org" + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.2" path_provider_windows: dependency: transitive description: name: path_provider_windows - url: "https://pub.dartlang.org" + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" source: hosted - version: "2.0.3" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.1" + version: "2.3.0" percent_indicator: dependency: "direct main" description: name: percent_indicator - url: "https://pub.dartlang.org" + sha256: "0c9824a4e10f19bb56bac9b0998765fdd665199a8b1eb5859854a26e8ef71fd7" + url: "https://pub.dev" source: hosted - version: "4.2.2" + version: "3.4.0" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646" + url: "https://pub.dev" source: hosted - version: "4.2.0" + version: "6.1.0" photo_view: dependency: "direct main" description: name: photo_view - url: "https://pub.dartlang.org" + sha256: "1fc3d970a91295fbd1364296575f854c9863f225505c28c46e0a03e48960c75e" + url: "https://pub.dev" source: hosted - version: "0.12.0" + version: "0.15.0" pinput: dependency: "direct main" description: name: pinput - url: "https://pub.dartlang.org" + sha256: "27eb69042f75755bdb6544f6e79a50a6ed09d6e97e2d75c8421744df1e392949" + url: "https://pub.dev" source: hosted version: "1.2.2" platform: dependency: transitive description: name: platform - url: "https://pub.dartlang.org" + sha256: ebc79f16b5f6b609aad4a5e63447d4795d16f7adee46e93ed03200848c006735 + url: "https://pub.dev" source: hosted version: "3.0.0" platform_detect: dependency: "direct main" description: name: platform_detect - url: "https://pub.dartlang.org" + sha256: "5127f442a9dcbb824948dbc0df57d2ca1d3ac8638f122ae2b0c6c51391f1d026" + url: "https://pub.dev" source: hosted version: "2.0.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.8" + posix: + dependency: transitive + description: + name: posix + sha256: "185ef7606574f789b40f289c233efa52e96dead518aed988e040a10737febb07" + url: "https://pub.dev" + source: hosted + version: "6.5.0" process: dependency: transitive description: name: process - url: "https://pub.dartlang.org" + sha256: ca157bb5ee3a2dce23ac17bac6d5e54c9d7d1b693f560b606a84aacd2f3c54f8 + url: "https://pub.dev" source: hosted version: "4.2.3" + provider: + dependency: transitive + description: + name: provider + sha256: "4e82183fa20e5ca25703ead7e05de9e4cceed1fbd1eadc1ac3cb6f565a09f272" + url: "https://pub.dev" + source: hosted + version: "6.1.5+1" pub_semver: dependency: transitive description: name: pub_semver - url: "https://pub.dartlang.org" + sha256: "59ed538734419e81f7fc18c98249ae72c3c7188bdd9dceff2840585227f79843" + url: "https://pub.dev" source: hosted version: "2.0.0" pull_to_refresh: dependency: "direct main" description: name: pull_to_refresh - url: "https://pub.dartlang.org" + sha256: bbadd5a931837b57739cf08736bea63167e284e71fb23b218c8c9a6e042aad12 + url: "https://pub.dev" source: hosted version: "2.0.0" redux: dependency: transitive description: name: redux - url: "https://pub.dartlang.org" + sha256: "1e86ed5b1a9a717922d0a0ca41f9bf49c1a587d50050e9426fc65b14e85ec4d7" + url: "https://pub.dev" source: hosted version: "5.0.0" responsive_builder: dependency: "direct main" description: name: responsive_builder - url: "https://pub.dartlang.org" + sha256: "64a5ef3fbe3628e4588a0c2391c3186300e76f58621d8135cc77aac816255a3e" + url: "https://pub.dev" source: hosted - version: "0.4.1" + version: "0.7.1" rxdart: dependency: transitive description: name: rxdart - url: "https://pub.dartlang.org" + sha256: e59cd2626a88e4543d5940fa3e128219fb747bf8cac1793cd0c4ed8243e853d9 + url: "https://pub.dev" source: hosted version: "0.27.1" - searchable_dropdown: - dependency: "direct main" - description: - name: searchable_dropdown - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.3" - sentry: + sanitize_html: dependency: transitive description: - name: sentry - url: "https://pub.dartlang.org" + name: sanitize_html + sha256: "12669c4a913688a26555323fb9cec373d8f9fbe091f2d01c40c723b33caa8989" + url: "https://pub.dev" source: hosted - version: "5.1.0" + version: "2.1.0" share: dependency: "direct main" description: name: share - url: "https://pub.dartlang.org" + sha256: "97e6403f564ed1051a01534c2fc919cb6e40ea55e60a18ec23cee6e0ce19f4be" + url: "https://pub.dev" source: hosted version: "2.0.4" - simple_animations: + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5" + url: "https://pub.dev" + source: hosted + version: "2.5.3" + shared_preferences_android: dependency: transitive description: - name: simple_animations - url: "https://pub.dartlang.org" + name: shared_preferences_android + sha256: bd14436108211b0d4ee5038689a56d4ae3620fd72fd6036e113bf1345bc74d9e + url: "https://pub.dev" source: hosted - version: "4.2.0" + version: "2.4.13" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "6a52cfcdaeac77cad8c97b539ff688ccfc458c007b4db12be584fbe5c0e49e03" + url: "https://pub.dev" + source: hosted + version: "2.5.4" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019 + url: "https://pub.dev" + source: hosted + version: "2.4.3" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1" + url: "https://pub.dev" + source: hosted + version: "2.4.1" sky_engine: dependency: transitive description: flutter source: sdk - version: "0.0.99" - smooth_star_rating: + version: "0.0.0" + smooth_star_rating_nsafe: dependency: "direct main" description: - name: smooth_star_rating - url: "https://pub.dartlang.org" + name: smooth_star_rating_nsafe + sha256: "11bb1e4736c0be3bd510a67598e94166c155cbf01ee8cef0c745bcc6ee315fdd" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.0.0+1" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: d5f89a9e52b36240a80282b3dc0667dd36e53459717bb17b8fb102d30496606a + url: "https://pub.dev" source: hosted version: "1.8.1" - splashscreen: - dependency: "direct main" - description: - name: splashscreen - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.5" sqflite: dependency: transitive description: name: sqflite - url: "https://pub.dartlang.org" + sha256: e2297b1da52f127bc7a3da11439985d9b536f75070f3325e62ada69a5c585d03 + url: "https://pub.dev" source: hosted - version: "2.0.0+3" + version: "2.4.2" + sqflite_android: + dependency: transitive + description: + name: sqflite_android + sha256: "2b3070c5fa881839f8b402ee4a39c1b4d561704d4ebbbcfb808a119bc2a1701b" + url: "https://pub.dev" + source: hosted + version: "2.4.1" sqflite_common: dependency: transitive description: name: sqflite_common - url: "https://pub.dartlang.org" + sha256: "84731e8bfd8303a3389903e01fb2141b6e59b5973cacbb0929021df08dddbe8b" + url: "https://pub.dev" source: hosted - version: "2.0.0+2" - stack_trace: + version: "2.5.5" + sqflite_darwin: dependency: transitive description: - name: stack_trace - url: "https://pub.dartlang.org" + name: sqflite_darwin + sha256: "279832e5cde3fe99e8571879498c9211f3ca6391b0d818df4e17d9fff5c6ccb3" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "2.4.2" + sqflite_platform_interface: + dependency: transitive + description: + name: sqflite_platform_interface + sha256: "8dd4515c7bdcae0a785b0062859336de775e8c65db81ae33dd5445f35be61920" + url: "https://pub.dev" + source: hosted + version: "2.4.0" stream_transform: dependency: transitive description: name: stream_transform - url: "https://pub.dartlang.org" + sha256: ed464977cb26a1f41537e177e190c67223dbd9f4f683489b6ab2e5d211ec564e + url: "https://pub.dev" source: hosted version: "2.0.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: dd11571b8a03f7cadcf91ec26a77e02bfbd6bbba2a512924d3116646b4198fc4 + url: "https://pub.dev" source: hosted version: "1.1.0" stripe_payment: dependency: "direct main" description: name: stripe_payment - url: "https://pub.dartlang.org" + sha256: "8c84e07127f821fdcb63697461fff3a68a693eee4286c28a4cb313517c46e9d6" + url: "https://pub.dev" source: hosted version: "1.1.4" - stripe_sdk: - dependency: "direct main" - description: - path: "." - ref: HEAD - resolved-ref: "1c614cbb782fa664a2dda65377c85520dfaea92e" - url: "https://github.com/ezet/stripe-sdk.git" - source: git - version: "5.0.0-nullsafety.1" synchronized: dependency: transitive description: name: synchronized - url: "https://pub.dartlang.org" + sha256: "271977ff1e9e82ceefb4f08424b8839f577c1852e0726b5ce855311b46d3ef83" + url: "https://pub.dev" source: hosted version: "3.0.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a88162591b02c1f3a3db3af8ce1ea2b374bd75a7bb8d5e353bcfbdc79d719830 + url: "https://pub.dev" source: hosted version: "1.2.0" - timezone: - dependency: transitive - description: - name: timezone - url: "https://pub.dartlang.org" - source: hosted - version: "0.7.0" toggle_switch: dependency: "direct main" description: name: toggle_switch - url: "https://pub.dartlang.org" + sha256: dca04512d7c23ed320d6c5ede1211a404f177d54d353bf785b07d15546a86ce5 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "2.3.0" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" universal_html: dependency: "direct main" description: name: universal_html - url: "https://pub.dartlang.org" + sha256: "5ff50b7c14d201421cf5230ec389a0591c4deb5c817c9d7ccca3b26fe5f31e34" + url: "https://pub.dev" source: hosted version: "2.0.8" universal_io: dependency: "direct main" description: name: universal_io - url: "https://pub.dartlang.org" + sha256: f63cbc48103236abf48e345e07a03ce5757ea86285ed313a6a032596ed9301e2 + url: "https://pub.dev" source: hosted - version: "2.0.4" + version: "2.3.1" url_launcher: dependency: "direct main" description: name: url_launcher - url: "https://pub.dartlang.org" + sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8 + url: "https://pub.dev" source: hosted - version: "6.1.5" + version: "6.3.2" url_launcher_android: dependency: transitive description: name: url_launcher_android - url: "https://pub.dartlang.org" + sha256: "81777b08c498a292d93ff2feead633174c386291e35612f8da438d6e92c4447e" + url: "https://pub.dev" source: hosted - version: "6.0.17" + version: "6.3.20" url_launcher_ios: dependency: transitive description: name: url_launcher_ios - url: "https://pub.dartlang.org" + sha256: d80b3f567a617cb923546034cc94bfe44eb15f989fe670b37f26abdb9d939cb7 + url: "https://pub.dev" source: hosted - version: "6.0.17" + version: "6.3.4" url_launcher_linux: dependency: transitive description: name: url_launcher_linux - url: "https://pub.dartlang.org" + sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.2.1" url_launcher_macos: dependency: transitive description: name: url_launcher_macos - url: "https://pub.dartlang.org" + sha256: c043a77d6600ac9c38300567f33ef12b0ef4f4783a2c1f00231d2b1941fea13f + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.2.3" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface - url: "https://pub.dartlang.org" + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.3.2" url_launcher_web: dependency: transitive description: name: url_launcher_web - url: "https://pub.dartlang.org" + sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2" + url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.4.1" url_launcher_windows: dependency: transitive description: name: url_launcher_windows - url: "https://pub.dartlang.org" + sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.1.4" url_strategy: dependency: "direct main" description: name: url_strategy - url: "https://pub.dartlang.org" + sha256: "42b68b42a9864c4d710401add17ad06e28f1c1d5500c93b98c431f6b0ea4ab87" + url: "https://pub.dev" source: hosted version: "0.2.0" uuid: dependency: "direct main" description: name: uuid - url: "https://pub.dartlang.org" + sha256: "1fef9e8e11e2991bb773070d4656b7bd5d850967a2456cfc83cf47925ba79489" + url: "https://pub.dev" source: hosted - version: "3.0.4" + version: "4.5.3" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" - webview_flutter: + version: "2.1.4" + web: dependency: transitive description: - name: webview_flutter - url: "https://pub.dartlang.org" + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" source: hosted - version: "3.0.4" - webview_flutter_android: - dependency: transitive - description: - name: webview_flutter_android - url: "https://pub.dartlang.org" - source: hosted - version: "2.9.1" - webview_flutter_platform_interface: - dependency: transitive - description: - name: webview_flutter_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.1" - webview_flutter_wkwebview: - dependency: transitive - description: - name: webview_flutter_wkwebview - url: "https://pub.dartlang.org" - source: hosted - version: "2.9.1" - win32: - dependency: transitive - description: - name: win32 - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.5" + version: "1.1.1" xdg_directories: dependency: transitive description: name: xdg_directories - url: "https://pub.dartlang.org" + sha256: "0186b3f2d66be9a12b0295bddcf8b6f8c0b0cc2f85c6287344e2a6366bc28457" + url: "https://pub.dev" source: hosted version: "0.2.0" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" source: hosted - version: "5.1.2" + version: "6.5.0" yaml: dependency: transitive description: name: yaml - url: "https://pub.dartlang.org" + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.2" youtube_player_iframe: dependency: "direct main" description: name: youtube_player_iframe - url: "https://pub.dartlang.org" + sha256: "606b3e0f9a975912005b3468cbd370df0008012e5564acc76b0bb033aa899351" + url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "2.2.2" sdks: - dart: ">=2.17.0 <3.0.0" - flutter: ">=3.0.0" + dart: ">=3.7.0 <4.0.0" + flutter: ">=3.29.0" diff --git a/pubspec.yaml b/pubspec.yaml index ccf6a26..5b548d5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,10 +15,13 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.1+2 +version: 2.0.0+1 +analyzer: + enable-experiment: + - non-nullable environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: flutter: @@ -31,67 +34,47 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.1 - font_awesome_flutter: ^9.1.0 - - responsive_builder: ^0.4.1 - fluro: ^2.0.3 - flutter_redux: ^0.8.2 + cupertino_icons: ^1.0.8 + responsive_builder: ^0.7.0 + fluro: ^2.0.5 + flutter_redux: ^0.10.0 event_bus: ^2.0.0 - cached_network_image: ^3.1.0 #^2.5.1 - pull_to_refresh: ^2.0.0 #^1.5.0 - splashscreen: ^1.3.5 - carousel_slider: ^4.0.0 - badges: ^2.0.1 - url_launcher: ^6.1.5 #^6.0.9 #^5.7.10 -# flutter_html: ^2.1.1 - flutter_markdown: ^0.6.4 #^0.5.1 - hive: ^2.0.4 #^1.4.4+1 - hive_flutter: ^1.1.0 #^0.3.1 - flutter_spinkit: ^5.0.0 - dio: ^4.0.0 #^3.0.10 - searchable_dropdown: ^1.1.3 - email_validator: ^2.0.1 - flappy_search_bar: ^1.7.2 - flutter_launcher_icons: ^0.9.1 #^0.8.1 -# package_info: ^2.0.2 - catcher: ^0.6.8 #^0.4.2 - share: ^2.0.4 #^0.6.5+4 - universal_io: ^2.0.4 #^1.0.2 - path_provider: ^2.0.2 #^1.6.28 -# path_provider: ^2.0.1 + cached_network_image: ^3.3.1 + pull_to_refresh: ^2.0.0 + carousel_slider: ^5.0.0 + badges: ^3.1.2 + url_launcher: ^6.3.1 + flutter_markdown: ^0.7.1 + shared_preferences: ^2.2.3 + flutter_spinkit: ^5.2.1 + dio: ^5.4.3+1 + flutter_searchable_dropdown: ^2.0.0 + email_validator: ^2.1.17 + flutter_launcher_icons: ^0.13.1 + share: ^2.0.4 + universal_io: ^2.2.2 + path_provider: ^2.1.3 platform_detect: ^2.0.0 - flutter_inappwebview: ^5.3.2 #^4.0.0+4 - youtube_player_iframe: ^2.2.1 #^1.2.0+2 - fluttertoast: ^8.0.8 #^7.1.8 - percent_indicator: ^4.2.2 #^3.0.1 - image_picker: ^0.8.0+3 #^0.6.7+22 - countdown: ^0.1.0 - gender_selection: ^1.0.0 -# uni_links: ^0.5.1 #^0.4.0 - photo_view: ^0.12.0 - flutter_dash: ^0.0.1 - smooth_star_rating: ^1.1.1 -# tesseract_ocr: ^0.3.1 -# local_auth: ^1.1.0 - toggle_switch: ^1.2.0 + flutter_inappwebview: ^5.3.2 + youtube_player_iframe: ^2.2.2 + fluttertoast: ^8.0.7 + percent_indicator: ^3.0.1 + image_picker: ^0.8.4+2 + gender_picker: ^1.1.0 + photo_view: ^0.15.0 + flutter_dash: ^1.0.0 + toggle_switch: ^2.3.0 pinput: ^1.2.0 - google_maps_flutter: ^2.0.6 #^1.2.0 - stripe_payment: ^1.0.10 -# stripe_sdk: -# git: -# url: git://github.com/romme86/stripe-sdk.git - stripe_sdk: - git: - url: https://github.com/ezet/stripe-sdk.git - uuid: ^3.0.4 #^2.2.2 - ffi: ^1.0.0 -# firebase_messaging: ^10.0.4 #^7.0.3 - flutter_local_notifications: ^8.1.1 #^4.0.1+2 + google_maps_flutter: ^2.6.1 + stripe_payment: ^1.1.4 + flutter_staggered_grid_view: ^0.4.0 + uuid: ^4.4.0 + ffi: ^2.1.2 geolocator: ^7.4.0 #^6.2.1 url_strategy: ^0.2.0 hovering: ^1.0.4 universal_html: ^2.0.8 + smooth_star_rating_nsafe: ^1.0.0+1 #dev_dependencies: # flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 0e707e1..043a96f 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,12 +6,12 @@ #include "generated_plugin_registrant.h" -#include -#include +#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { - CatcherPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("CatcherPlugin")); - UrlLauncherPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("UrlLauncherPlugin")); + FileSelectorWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FileSelectorWindows")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 3e2cef5..a95e267 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,7 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST - catcher + file_selector_windows url_launcher_windows )