diff --git a/LabelStoreMax/CHANGELOG.md b/LabelStoreMax/CHANGELOG.md
index e412825..1147156 100644
--- a/LabelStoreMax/CHANGELOG.md
+++ b/LabelStoreMax/CHANGELOG.md
@@ -1,3 +1,11 @@
+## [6.0.0] - 2022-05-19
+
+* Migrate to Nylo 3.x
+* Null safety
+* Min dart version 2.17
+* Refactor product detail screen
+* Pubspec.yaml dependency updates
+
## [5.8.0] - 2022-03-29
* Add phone number to customer input form
diff --git a/LabelStoreMax/README.md b/LabelStoreMax/README.md
index 77e2641..bdd377f 100644
--- a/LabelStoreMax/README.md
+++ b/LabelStoreMax/README.md
@@ -4,7 +4,7 @@
# WooCommerce App: Label StoreMax
-### Label StoreMax - v5.8.0
+### Label StoreMax - v6.0.0
[Official WooSignal WooCommerce App](https://woosignal.com)
diff --git a/LabelStoreMax/ios/Runner/Info.plist b/LabelStoreMax/ios/Runner/Info.plist
index 8707779..8eb5192 100644
--- a/LabelStoreMax/ios/Runner/Info.plist
+++ b/LabelStoreMax/ios/Runner/Info.plist
@@ -61,5 +61,7 @@
UIViewControllerBasedStatusBarAppearance
+ CADisableMinimumFrameDurationOnPhone
+
diff --git a/LabelStoreMax/lib/app/controllers/controller.dart b/LabelStoreMax/lib/app/controllers/controller.dart
index 9b0a405..6faa510 100644
--- a/LabelStoreMax/lib/app/controllers/controller.dart
+++ b/LabelStoreMax/lib/app/controllers/controller.dart
@@ -8,7 +8,7 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-import 'package:nylo_support/controllers/controller.dart';
+import 'package:nylo_framework/nylo_framework.dart';
/// Base Controller for the Nylo
/// See more on controllers here - https://nylo.dev/docs/2.x/controllers
diff --git a/LabelStoreMax/lib/app/controllers/customer_orders_loader_controller.dart b/LabelStoreMax/lib/app/controllers/customer_orders_loader_controller.dart
index 546132e..2e121f8 100644
--- a/LabelStoreMax/lib/app/controllers/customer_orders_loader_controller.dart
+++ b/LabelStoreMax/lib/app/controllers/customer_orders_loader_controller.dart
@@ -7,8 +7,6 @@
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
-import 'package:flutter/cupertino.dart';
import 'package:flutter_app/app/controllers/woosignal_api_loader_controller.dart';
import 'package:woosignal/models/response/order.dart';
@@ -17,9 +15,9 @@ class CustomerOrdersLoaderController
CustomerOrdersLoaderController();
Future loadOrders(
- {@required bool Function(bool hasProducts) hasResults,
- @required void Function() didFinish,
- @required String userId}) async {
+ {required bool Function(bool hasProducts) hasResults,
+ required void Function() didFinish,
+ required String userId}) async {
await load(
hasResults: hasResults,
didFinish: didFinish,
diff --git a/LabelStoreMax/lib/app/controllers/leave_review_controller.dart b/LabelStoreMax/lib/app/controllers/leave_review_controller.dart
index 2524b13..b97e7e4 100644
--- a/LabelStoreMax/lib/app/controllers/leave_review_controller.dart
+++ b/LabelStoreMax/lib/app/controllers/leave_review_controller.dart
@@ -12,10 +12,8 @@ import 'controller.dart';
import 'package:flutter/widgets.dart';
class LeaveReviewController extends Controller {
-
@override
construct(BuildContext context) {
super.construct(context);
-
}
-}
\ No newline at end of file
+}
diff --git a/LabelStoreMax/lib/app/controllers/product_category_search_loader_controller.dart b/LabelStoreMax/lib/app/controllers/product_category_search_loader_controller.dart
index 9c0b31d..1e8dd83 100644
--- a/LabelStoreMax/lib/app/controllers/product_category_search_loader_controller.dart
+++ b/LabelStoreMax/lib/app/controllers/product_category_search_loader_controller.dart
@@ -8,7 +8,6 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-import 'package:flutter/cupertino.dart';
import 'package:flutter_app/app/controllers/woosignal_api_loader_controller.dart';
import 'package:woosignal/models/response/product_category.dart';
import 'package:woosignal/models/response/products.dart';
@@ -18,19 +17,19 @@ class ProductCategorySearchLoaderController
ProductCategorySearchLoaderController();
Future loadProducts(
- {@required bool Function(bool hasProducts) hasResults,
- @required void Function() didFinish,
- @required ProductCategory productCategory}) async {
+ {required bool Function(bool hasProducts) hasResults,
+ required void Function() didFinish,
+ required ProductCategory? productCategory}) async {
await load(
- hasResults: hasResults,
- didFinish: didFinish,
- apiQuery: (api) => api.getProducts(
- perPage: 50,
- category: productCategory.id.toString(),
- page: page,
- status: "publish",
- stockStatus: "instock",
- ),
+ hasResults: hasResults,
+ didFinish: didFinish,
+ apiQuery: (api) => api.getProducts(
+ perPage: 50,
+ category: productCategory!.id.toString(),
+ page: page,
+ status: "publish",
+ stockStatus: "instock",
+ ),
);
}
}
diff --git a/LabelStoreMax/lib/app/controllers/product_detail_controller.dart b/LabelStoreMax/lib/app/controllers/product_detail_controller.dart
index c9ee6ad..27cee47 100644
--- a/LabelStoreMax/lib/app/controllers/product_detail_controller.dart
+++ b/LabelStoreMax/lib/app/controllers/product_detail_controller.dart
@@ -16,44 +16,46 @@ import 'package:flutter_app/bootstrap/helpers.dart';
import 'package:nylo_framework/nylo_framework.dart';
import 'package:woosignal/models/response/products.dart';
import 'package:woosignal/models/response/product_variation.dart'
-as ws_product_variation;
+ as ws_product_variation;
import 'controller.dart';
class ProductDetailController extends Controller {
int quantity = 1;
- Product product;
+ Product? product;
@override
construct(BuildContext context) {
super.construct(context);
- product = data() as Product;
+ product = data() as Product?;
}
viewExternalProduct() {
- if (product.externalUrl != null && product.externalUrl.isNotEmpty) {
- openBrowserTab(url: product.externalUrl);
+ if (product!.externalUrl != null && product!.externalUrl!.isNotEmpty) {
+ openBrowserTab(url: product!.externalUrl!);
}
}
- itemAddToCart({@required CartLineItem cartLineItem, @required Function onSuccess}) async {
+ itemAddToCart(
+ {required CartLineItem cartLineItem, required Function onSuccess}) async {
await Cart.getInstance.addToCart(cartLineItem: cartLineItem);
- showStatusAlert(context,
- title: trans("Success"),
- subtitle: trans("Added to cart"),
- duration: 1,
- icon: Icons.add_shopping_cart,
+ showStatusAlert(
+ context,
+ title: trans("Success"),
+ subtitle: trans("Added to cart"),
+ duration: 1,
+ icon: Icons.add_shopping_cart,
);
onSuccess();
}
- addQuantityTapped({@required Function onSuccess}) {
- if (product.manageStock != null && product.manageStock == true) {
- if (quantity >= product.stockQuantity) {
- showToastNotification(context,
+ addQuantityTapped({required Function onSuccess}) {
+ if (product!.manageStock != null && product!.manageStock == true) {
+ if (quantity >= product!.stockQuantity!) {
+ showToastNotification(context!,
title: trans("Maximum quantity reached"),
description:
- "${trans("Sorry, only")} ${product.stockQuantity} ${trans("left")}",
+ "${trans("Sorry, only")} ${product!.stockQuantity} ${trans("left")}",
style: ToastNotificationStyleType.INFO);
return;
}
@@ -64,14 +66,16 @@ class ProductDetailController extends Controller {
}
}
- removeQuantityTapped({@required Function onSuccess}) {
+ removeQuantityTapped({required Function onSuccess}) {
if ((quantity - 1) >= 1) {
quantity--;
onSuccess();
}
}
- toggleWishList({@required Function onSuccess, @required WishlistAction wishlistAction}) async {
+ toggleWishList(
+ {required Function onSuccess,
+ required WishlistAction wishlistAction}) async {
String subtitleMsg;
if (wishlistAction == WishlistAction.remove) {
await removeWishlistProduct(product: product);
@@ -80,7 +84,8 @@ class ProductDetailController extends Controller {
await saveWishlistProduct(product: product);
subtitleMsg = trans("This product has been added to your wishlist");
}
- showStatusAlert(context,
+ showStatusAlert(
+ context,
title: trans("Success"),
subtitle: subtitleMsg,
icon: Icons.favorite,
@@ -90,18 +95,18 @@ class ProductDetailController extends Controller {
onSuccess();
}
- ws_product_variation.ProductVariation findProductVariation(
- {@required Map tmpAttributeObj,
- @required List productVariations}) {
- ws_product_variation.ProductVariation tmpProductVariation;
+ ws_product_variation.ProductVariation? findProductVariation(
+ {required Map tmpAttributeObj,
+ required List productVariations}) {
+ ws_product_variation.ProductVariation? tmpProductVariation;
- Map tmpSelectedObj = {};
+ Map tmpSelectedObj = {};
for (var attributeObj in tmpAttributeObj.values) {
tmpSelectedObj[attributeObj["name"]] = attributeObj["value"];
}
for (var productVariation in productVariations) {
- Map tmpVariations = {};
+ Map tmpVariations = {};
for (var attr in productVariation.attributes) {
tmpVariations[attr.name] = attr.option;
@@ -114,4 +119,4 @@ class ProductDetailController extends Controller {
return tmpProductVariation;
}
-}
\ No newline at end of file
+}
diff --git a/LabelStoreMax/lib/app/controllers/product_loader_controller.dart b/LabelStoreMax/lib/app/controllers/product_loader_controller.dart
index f7cc293..7d3e498 100644
--- a/LabelStoreMax/lib/app/controllers/product_loader_controller.dart
+++ b/LabelStoreMax/lib/app/controllers/product_loader_controller.dart
@@ -8,18 +8,16 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-import 'package:flutter/cupertino.dart';
import 'package:flutter_app/app/controllers/woosignal_api_loader_controller.dart';
import 'package:woosignal/models/response/products.dart';
class ProductLoaderController extends WooSignalApiLoaderController {
ProductLoaderController();
- Future loadProducts({
- @required bool Function(bool hasProducts) hasResults,
- @required void Function() didFinish,
- List productIds = const []
- }) async {
+ Future loadProducts(
+ {required bool Function(bool hasProducts) hasResults,
+ required void Function() didFinish,
+ List? productIds = const []}) async {
await load(
hasResults: hasResults,
didFinish: didFinish,
diff --git a/LabelStoreMax/lib/app/controllers/product_reviews_controller.dart b/LabelStoreMax/lib/app/controllers/product_reviews_controller.dart
index b4f255e..cd238ab 100644
--- a/LabelStoreMax/lib/app/controllers/product_reviews_controller.dart
+++ b/LabelStoreMax/lib/app/controllers/product_reviews_controller.dart
@@ -12,11 +12,8 @@ import 'controller.dart';
import 'package:flutter/widgets.dart';
class ProductReviewsController extends Controller {
-
@override
construct(BuildContext context) {
super.construct(context);
-
}
-
-}
+}
diff --git a/LabelStoreMax/lib/app/controllers/product_reviews_loader_controller.dart b/LabelStoreMax/lib/app/controllers/product_reviews_loader_controller.dart
index 68e1098..a3c5f31 100644
--- a/LabelStoreMax/lib/app/controllers/product_reviews_loader_controller.dart
+++ b/LabelStoreMax/lib/app/controllers/product_reviews_loader_controller.dart
@@ -8,27 +8,27 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-import 'package:flutter/cupertino.dart';
import 'package:flutter_app/app/controllers/woosignal_api_loader_controller.dart';
import 'package:woosignal/models/response/product_review.dart';
import 'package:woosignal/models/response/products.dart';
-class ProductReviewsLoaderController extends WooSignalApiLoaderController {
+class ProductReviewsLoaderController
+ extends WooSignalApiLoaderController {
ProductReviewsLoaderController();
Future loadProductReviews({
- @required Product product,
- @required bool Function(bool hasProducts) hasResults,
- @required void Function() didFinish,
+ required Product? product,
+ required bool Function(bool hasProducts) hasResults,
+ required void Function() didFinish,
}) async {
await load(
hasResults: hasResults,
didFinish: didFinish,
apiQuery: (api) => api.getProductReviews(
- product: [product.id],
- perPage: 50,
- page: page,
- status: "approved",
- ));
+ product: [product!.id!],
+ perPage: 50,
+ page: page,
+ status: "approved",
+ ));
}
}
diff --git a/LabelStoreMax/lib/app/controllers/product_search_loader_controller.dart b/LabelStoreMax/lib/app/controllers/product_search_loader_controller.dart
index 00ec955..75712d5 100644
--- a/LabelStoreMax/lib/app/controllers/product_search_loader_controller.dart
+++ b/LabelStoreMax/lib/app/controllers/product_search_loader_controller.dart
@@ -8,7 +8,6 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-import 'package:flutter/cupertino.dart';
import 'package:flutter_app/app/controllers/woosignal_api_loader_controller.dart';
import 'package:woosignal/models/response/products.dart';
@@ -17,9 +16,9 @@ class ProductSearchLoaderController
ProductSearchLoaderController();
Future loadProducts(
- {@required bool Function(bool hasProducts) hasResults,
- @required void Function() didFinish,
- @required String search}) async {
+ {required bool Function(bool hasProducts) hasResults,
+ required void Function() didFinish,
+ required String? search}) async {
await load(
hasResults: hasResults,
didFinish: didFinish,
diff --git a/LabelStoreMax/lib/app/controllers/woosignal_api_loader_controller.dart b/LabelStoreMax/lib/app/controllers/woosignal_api_loader_controller.dart
index b7d45a2..11e669a 100644
--- a/LabelStoreMax/lib/app/controllers/woosignal_api_loader_controller.dart
+++ b/LabelStoreMax/lib/app/controllers/woosignal_api_loader_controller.dart
@@ -8,7 +8,6 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-import 'package:flutter/cupertino.dart';
import 'package:flutter_app/bootstrap/helpers.dart';
import 'package:woosignal/woosignal.dart';
@@ -20,15 +19,15 @@ class WooSignalApiLoaderController {
WooSignalApiLoaderController();
Future load(
- {@required bool Function(bool hasProducts) hasResults,
- @required void Function() didFinish,
- @required Future> Function(WooSignal query) apiQuery}) async {
+ {required bool Function(bool hasProducts) hasResults,
+ required void Function() didFinish,
+ required Future> Function(WooSignal query) apiQuery}) async {
if (_waitForNextRequest) {
return;
}
_waitForNextRequest = true;
- List apiResults = await appWooSignal((api) => apiQuery(api));
+ List apiResults = await (appWooSignal((api) => apiQuery(api)));
if (!hasResults(apiResults.isNotEmpty)) {
return;
@@ -41,9 +40,7 @@ class WooSignalApiLoaderController {
didFinish();
}
- List getResults() {
- return _results;
- }
+ List getResults() => _results;
void clear() {
_results = [];
diff --git a/LabelStoreMax/lib/app/events/login_event.dart b/LabelStoreMax/lib/app/events/login_event.dart
new file mode 100644
index 0000000..132e954
--- /dev/null
+++ b/LabelStoreMax/lib/app/events/login_event.dart
@@ -0,0 +1,15 @@
+import 'package:nylo_framework/nylo_framework.dart';
+
+class LoginEvent implements NyEvent {
+ @override
+ final listeners = {
+ DefaultListener: DefaultListener(),
+ };
+}
+
+class DefaultListener extends NyListener {
+ @override
+ handle(dynamic event) async {
+ // handle the payload from event
+ }
+}
diff --git a/LabelStoreMax/lib/app/events/logout_event.dart b/LabelStoreMax/lib/app/events/logout_event.dart
new file mode 100644
index 0000000..6f11af7
--- /dev/null
+++ b/LabelStoreMax/lib/app/events/logout_event.dart
@@ -0,0 +1,13 @@
+import 'package:nylo_framework/nylo_framework.dart';
+
+class LogoutEvent implements NyEvent {
+ @override
+ final listeners = {DefaultListener: DefaultListener()};
+}
+
+class DefaultListener extends NyListener {
+ @override
+ handle(dynamic event) async {
+ // handle the payload from event
+ }
+}
diff --git a/LabelStoreMax/lib/app/models/billing_details.dart b/LabelStoreMax/lib/app/models/billing_details.dart
index 400aeba..66f2d84 100644
--- a/LabelStoreMax/lib/app/models/billing_details.dart
+++ b/LabelStoreMax/lib/app/models/billing_details.dart
@@ -11,9 +11,9 @@
import 'package:flutter_app/app/models/customer_address.dart';
class BillingDetails {
- CustomerAddress billingAddress;
- CustomerAddress shippingAddress;
- bool rememberDetails;
+ CustomerAddress? billingAddress;
+ CustomerAddress? shippingAddress;
+ bool? rememberDetails;
void initSession() {
billingAddress = CustomerAddress();
diff --git a/LabelStoreMax/lib/app/models/bottom_nav_item.dart b/LabelStoreMax/lib/app/models/bottom_nav_item.dart
index ab339e7..ef109d5 100644
--- a/LabelStoreMax/lib/app/models/bottom_nav_item.dart
+++ b/LabelStoreMax/lib/app/models/bottom_nav_item.dart
@@ -15,5 +15,8 @@ class BottomNavItem {
BottomNavigationBarItem bottomNavigationBarItem;
Widget tabWidget;
- BottomNavItem({this.id, this.bottomNavigationBarItem, this.tabWidget});
+ BottomNavItem(
+ {required this.id,
+ required this.bottomNavigationBarItem,
+ required this.tabWidget});
}
diff --git a/LabelStoreMax/lib/app/models/cart.dart b/LabelStoreMax/lib/app/models/cart.dart
index 4b26a90..e66df9d 100644
--- a/LabelStoreMax/lib/app/models/cart.dart
+++ b/LabelStoreMax/lib/app/models/cart.dart
@@ -10,14 +10,14 @@
import 'dart:convert';
-import 'package:flutter/cupertino.dart';
+import 'package:collection/collection.dart' show IterableExtension;
import 'package:flutter_app/app/models/cart_line_item.dart';
import 'package:flutter_app/app/models/checkout_session.dart';
import 'package:flutter_app/app/models/shipping_type.dart';
import 'package:flutter_app/bootstrap/app_helper.dart';
import 'package:flutter_app/bootstrap/helpers.dart';
import 'package:flutter_app/bootstrap/shared_pref/shared_key.dart';
-import 'package:nylo_support/helpers/helper.dart';
+import 'package:nylo_framework/nylo_framework.dart';
import 'package:woosignal/models/response/shipping_method.dart';
import 'package:woosignal/models/response/tax_rate.dart';
@@ -27,7 +27,7 @@ class Cart {
Future> getCart() async {
List cartLineItems = [];
- String currentCartArrJSON = await NyStorage.read(SharedKey.cart);
+ String? currentCartArrJSON = await (NyStorage.read(SharedKey.cart));
if (currentCartArrJSON != null) {
cartLineItems = (jsonDecode(currentCartArrJSON) as List)
@@ -38,15 +38,14 @@ class Cart {
return cartLineItems;
}
- Future addToCart({@required CartLineItem cartLineItem}) async {
+ Future addToCart({required CartLineItem cartLineItem}) async {
List cartLineItems = await getCart();
if (cartLineItem.variationId != null &&
- cartLineItems.firstWhere(
- (i) => (i.productId == cartLineItem.productId &&
+ cartLineItems.firstWhereOrNull((i) =>
+ (i.productId == cartLineItem.productId &&
i.variationId == cartLineItem.variationId &&
- i.variationOptions == cartLineItem.variationOptions),
- orElse: () => null) !=
+ i.variationOptions == cartLineItem.variationOptions)) !=
null) {
cartLineItems.removeWhere((item) =>
item.productId == cartLineItem.productId &&
@@ -55,8 +54,8 @@ class Cart {
}
if (cartLineItem.variationId == null &&
- cartLineItems.firstWhere((i) => i.productId == cartLineItem.productId,
- orElse: () => null) !=
+ cartLineItems.firstWhereOrNull(
+ (i) => i.productId == cartLineItem.productId) !=
null) {
cartLineItems
.removeWhere((item) => item.productId == cartLineItem.productId);
@@ -80,7 +79,7 @@ class Cart {
total = total - double.parse(discountAmount);
}
- if (withFormat != null && withFormat == true) {
+ if (withFormat == true) {
return formatDoubleCurrency(total: total);
}
return total.toStringAsFixed(2);
@@ -92,15 +91,15 @@ class Cart {
for (var cartItem in cartLineItems) {
subtotal += (parseWcPrice(cartItem.subtotal) * cartItem.quantity);
}
- if (withFormat != null && withFormat == true) {
+ if (withFormat == true) {
return formatDoubleCurrency(total: subtotal);
}
return subtotal.toStringAsFixed(2);
}
updateQuantity(
- {@required CartLineItem cartLineItem,
- @required int incrementQuantity}) async {
+ {required CartLineItem cartLineItem,
+ required int incrementQuantity}) async {
List cartLineItems = await getCart();
List tmpCartItem = [];
for (var cartItem in cartLineItems) {
@@ -124,7 +123,7 @@ class Cart {
.join(",");
}
- removeCartItemForIndex({@required int index}) async {
+ removeCartItemForIndex({required int index}) async {
List cartLineItems = await getCart();
cartLineItems.removeAt(index);
await saveCartToPref(cartLineItems: cartLineItems);
@@ -132,12 +131,12 @@ class Cart {
clear() async => NyStorage.delete(SharedKey.cart);
- saveCartToPref({@required List cartLineItems}) async {
+ saveCartToPref({required List cartLineItems}) async {
String json = jsonEncode(cartLineItems.map((i) => i.toJson()).toList());
await NyStorage.store(SharedKey.cart, json);
}
- Future taxAmount(TaxRate taxRate) async {
+ Future taxAmount(TaxRate? taxRate) async {
double subtotal = 0;
double shippingTotal = 0;
@@ -150,7 +149,7 @@ class Cart {
cartItems.where((c) => c.taxStatus == 'taxable').toList();
double cartSubtotal = 0;
- if (AppHelper.instance.appConfig.productPricesIncludeTax == 1 &&
+ if (AppHelper.instance.appConfig!.productPricesIncludeTax == 1 &&
taxableCartLines.isNotEmpty) {
cartSubtotal = taxableCartLines
.map((m) => parseWcPrice(m.subtotal) * m.quantity)
@@ -163,22 +162,20 @@ class Cart {
subtotal = cartSubtotal;
- ShippingType shippingType = CheckoutSession.getInstance.shippingType;
+ ShippingType? shippingType = CheckoutSession.getInstance.shippingType;
if (shippingType != null) {
switch (shippingType.methodId) {
case "flat_rate":
FlatRate flatRate = (shippingType.object as FlatRate);
- if (flatRate.taxable != null && flatRate.taxable) {
- shippingTotal += parseWcPrice(
- shippingType.cost == null || shippingType.cost == ""
- ? "0"
- : shippingType.cost);
+ if (flatRate.taxable != null && flatRate.taxable!) {
+ shippingTotal +=
+ parseWcPrice(shippingType.cost == "" ? "0" : shippingType.cost);
}
break;
case "local_pickup":
LocalPickup localPickup = (shippingType.object as LocalPickup);
- if (localPickup.taxable != null && localPickup.taxable) {
+ if (localPickup.taxable != null && localPickup.taxable!) {
shippingTotal += parseWcPrice(
(localPickup.cost == null || localPickup.cost == ""
? "0"
@@ -192,10 +189,10 @@ class Cart {
double total = 0;
if (subtotal != 0) {
- total += ((parseWcPrice(taxRate.rate) * subtotal) / 100);
+ total += ((parseWcPrice(taxRate!.rate) * subtotal) / 100);
}
if (shippingTotal != 0) {
- total += ((parseWcPrice(taxRate.rate) * shippingTotal) / 100);
+ total += ((parseWcPrice(taxRate!.rate) * shippingTotal) / 100);
}
return (total).toStringAsFixed(2);
}
@@ -213,10 +210,10 @@ class Cart {
for (var cartItem in cartLineItems) {
bool canContinue = true;
- if (checkoutSession.coupon.excludedProductCategories.isNotEmpty) {
+ if (checkoutSession.coupon!.excludedProductCategories!.isNotEmpty) {
for (var excludedProductCategory
- in checkoutSession.coupon.excludedProductCategories) {
- if (cartItem.categories
+ in checkoutSession.coupon!.excludedProductCategories!) {
+ if (cartItem.categories!
.map((category) => category.id)
.contains(excludedProductCategory)) {
canContinue = false;
@@ -225,10 +222,10 @@ class Cart {
}
}
- if (checkoutSession.coupon.productCategories.isNotEmpty) {
+ if (checkoutSession.coupon!.productCategories!.isNotEmpty) {
for (var productCategories
- in checkoutSession.coupon.productCategories) {
- if (cartItem.categories
+ in checkoutSession.coupon!.productCategories!) {
+ if (cartItem.categories!
.map((category) => category.id)
.contains(productCategories) ==
false) {
@@ -242,41 +239,41 @@ class Cart {
continue;
}
- if (checkoutSession.coupon.excludeSaleItems == true &&
+ if (checkoutSession.coupon!.excludeSaleItems == true &&
cartItem.onSale == true) {
continue;
}
- if (checkoutSession.coupon.excludedProductIds.isNotEmpty &&
- checkoutSession.coupon.excludedProductIds
+ if (checkoutSession.coupon!.excludedProductIds!.isNotEmpty &&
+ checkoutSession.coupon!.excludedProductIds!
.contains(cartItem.productId)) {
continue;
}
- if (checkoutSession.coupon.productIds.isNotEmpty &&
- !checkoutSession.coupon.productIds.contains(cartItem.productId)) {
+ if (checkoutSession.coupon!.productIds!.isNotEmpty &&
+ !checkoutSession.coupon!.productIds!.contains(cartItem.productId)) {
continue;
}
subtotal += (parseWcPrice(cartItem.subtotal) * cartItem.quantity);
eligibleCartLineItems.add(cartItem);
}
- String discountType = checkoutSession.coupon.discountType;
- String amount = checkoutSession.coupon.amount;
+ String? discountType = checkoutSession.coupon!.discountType;
+ String? amount = checkoutSession.coupon!.amount;
// Percentage
if (discountType == 'percent') {
- return ((subtotal * double.parse(amount)) / 100).toStringAsFixed(2);
+ return ((subtotal * double.parse(amount!)) / 100).toStringAsFixed(2);
}
// Fixed cart
if (discountType == 'fixed_cart') {
- return (double.parse(amount)).toStringAsFixed(2);
+ return (double.parse(amount!)).toStringAsFixed(2);
}
// Fixed product
if (discountType == 'fixed_product') {
- return (eligibleCartLineItems.length * double.parse(amount))
+ return (eligibleCartLineItems.length * double.parse(amount!))
.toStringAsFixed(2);
}
return "0";
diff --git a/LabelStoreMax/lib/app/models/cart_line_item.dart b/LabelStoreMax/lib/app/models/cart_line_item.dart
index 68d55e5..c1bd09b 100644
--- a/LabelStoreMax/lib/app/models/cart_line_item.dart
+++ b/LabelStoreMax/lib/app/models/cart_line_item.dart
@@ -14,24 +14,24 @@ import 'package:woosignal/models/response/product_variation.dart';
import 'package:woosignal/models/response/products.dart' as ws_product;
class CartLineItem {
- String name;
- int productId;
- int variationId;
- int quantity;
- bool isManagedStock;
- int stockQuantity;
- String shippingClassId;
- String taxStatus;
- String taxClass;
- bool shippingIsTaxable;
- String subtotal;
- String total;
- String imageSrc;
- String variationOptions;
- List categories;
- bool onSale;
- String stockStatus;
- Object metaData = {};
+ String? name;
+ int? productId;
+ int? variationId;
+ int quantity = 0;
+ bool? isManagedStock;
+ int? stockQuantity;
+ String? shippingClassId;
+ String? taxStatus;
+ String? taxClass;
+ bool? shippingIsTaxable;
+ String? subtotal;
+ String? total;
+ String? imageSrc;
+ String? variationOptions;
+ List? categories;
+ bool? onSale;
+ String? stockStatus;
+ Object? metaData = {};
CartLineItem(
{this.name,
@@ -39,7 +39,7 @@ class CartLineItem {
this.variationId,
this.isManagedStock,
this.stockQuantity,
- this.quantity,
+ this.quantity = 1,
this.stockStatus,
this.shippingClassId,
this.taxStatus,
@@ -57,10 +57,11 @@ class CartLineItem {
return (quantity * parseWcPrice(subtotal)).toStringAsFixed(2);
}
- CartLineItem.fromProduct({int quantityAmount, ws_product.Product product}) {
+ CartLineItem.fromProduct(
+ {int? quantityAmount, required ws_product.Product product}) {
name = product.name;
productId = product.id;
- quantity = quantityAmount;
+ quantity = quantityAmount ?? 1;
taxStatus = product.taxStatus;
shippingClassId = product.shippingClassId.toString();
subtotal = product.price;
@@ -76,21 +77,21 @@ class CartLineItem {
}
CartLineItem.fromProductVariation(
- {int quantityAmount,
- List options,
- ws_product.Product product,
- ProductVariation productVariation}) {
- String imageSrc = getEnv("PRODUCT_PLACEHOLDER_IMAGE");
+ {int? quantityAmount,
+ required List options,
+ required ws_product.Product product,
+ required ProductVariation productVariation}) {
+ String? imageSrc = getEnv("PRODUCT_PLACEHOLDER_IMAGE");
if (product.images.isNotEmpty) {
imageSrc = product.images.first.src;
}
if (productVariation.image != null) {
- imageSrc = productVariation.image.src;
+ imageSrc = productVariation.image!.src;
}
name = product.name;
productId = product.id;
variationId = productVariation.id;
- quantity = quantityAmount;
+ quantity = quantityAmount ?? 1;
taxStatus = productVariation.taxStatus;
shippingClassId = productVariation.shippingClassId.toString();
subtotal = productVariation.price;
@@ -145,7 +146,7 @@ class CartLineItem {
'shipping_is_taxable': shippingIsTaxable,
'image_src': imageSrc,
'categories': categories != null
- ? categories.map((e) => e.toJson()).toList()
+ ? categories!.map((e) => e.toJson()).toList()
: [],
'variation_options': variationOptions,
'subtotal': subtotal,
diff --git a/LabelStoreMax/lib/app/models/checkout_session.dart b/LabelStoreMax/lib/app/models/checkout_session.dart
index 6f7f68c..08c14dd 100644
--- a/LabelStoreMax/lib/app/models/checkout_session.dart
+++ b/LabelStoreMax/lib/app/models/checkout_session.dart
@@ -16,21 +16,21 @@ import 'package:flutter_app/app/models/payment_type.dart';
import 'package:flutter_app/app/models/shipping_type.dart';
import 'package:flutter_app/bootstrap/helpers.dart';
import 'package:flutter_app/bootstrap/shared_pref/shared_key.dart';
-import 'package:nylo_support/helpers/helper.dart';
+import 'package:nylo_framework/nylo_framework.dart';
import 'package:woosignal/models/response/coupon.dart';
import 'package:woosignal/models/response/tax_rate.dart';
class CheckoutSession {
- bool shipToDifferentAddress = false;
+ bool? shipToDifferentAddress = false;
CheckoutSession._privateConstructor();
static final CheckoutSession getInstance =
CheckoutSession._privateConstructor();
- BillingDetails billingDetails;
- ShippingType shippingType;
- PaymentType paymentType;
- Coupon coupon;
+ BillingDetails? billingDetails;
+ ShippingType? shippingType;
+ PaymentType? paymentType;
+ Coupon? coupon;
void initSession() {
billingDetails = BillingDetails();
@@ -45,8 +45,8 @@ class CheckoutSession {
}
saveBillingAddress() async {
- CustomerAddress customerAddress =
- CheckoutSession.getInstance.billingDetails.billingAddress;
+ CustomerAddress? customerAddress =
+ CheckoutSession.getInstance.billingDetails!.billingAddress;
if (customerAddress == null) {
return;
@@ -56,9 +56,9 @@ class CheckoutSession {
await NyStorage.store(SharedKey.customerBillingDetails, billingAddress);
}
- Future getBillingAddress() async {
- String strCheckoutDetails =
- await NyStorage.read(SharedKey.customerBillingDetails);
+ Future getBillingAddress() async {
+ String? strCheckoutDetails =
+ await (NyStorage.read(SharedKey.customerBillingDetails));
if (strCheckoutDetails != null && strCheckoutDetails != "") {
return CustomerAddress.fromJson(jsonDecode(strCheckoutDetails));
@@ -70,8 +70,8 @@ class CheckoutSession {
await NyStorage.delete(SharedKey.customerBillingDetails);
saveShippingAddress() async {
- CustomerAddress customerAddress =
- CheckoutSession.getInstance.billingDetails.shippingAddress;
+ CustomerAddress? customerAddress =
+ CheckoutSession.getInstance.billingDetails!.shippingAddress;
if (customerAddress == null) {
return;
}
@@ -79,9 +79,9 @@ class CheckoutSession {
await NyStorage.store(SharedKey.customerShippingDetails, shippingAddress);
}
- Future getShippingAddress() async {
- String strCheckoutDetails =
- await NyStorage.read(SharedKey.customerShippingDetails);
+ Future getShippingAddress() async {
+ String? strCheckoutDetails =
+ await (NyStorage.read(SharedKey.customerShippingDetails));
if (strCheckoutDetails != null && strCheckoutDetails != "") {
return CustomerAddress.fromJson(jsonDecode(strCheckoutDetails));
}
@@ -91,19 +91,19 @@ class CheckoutSession {
clearShippingAddress() async =>
await NyStorage.delete(SharedKey.customerShippingDetails);
- Future total({bool withFormat = false, TaxRate taxRate}) async {
+ Future total({bool withFormat = false, TaxRate? taxRate}) async {
double totalCart = parseWcPrice(await Cart.getInstance.getTotal());
double totalShipping = 0;
- if (shippingType != null && shippingType.object != null) {
- switch (shippingType.methodId) {
+ if (shippingType != null && shippingType!.object != null) {
+ switch (shippingType!.methodId) {
case "flat_rate":
- totalShipping = parseWcPrice(shippingType.cost);
+ totalShipping = parseWcPrice(shippingType!.cost);
break;
case "free_shipping":
- totalShipping = parseWcPrice(shippingType.cost);
+ totalShipping = parseWcPrice(shippingType!.cost);
break;
case "local_pickup":
- totalShipping = parseWcPrice(shippingType.cost);
+ totalShipping = parseWcPrice(shippingType!.cost);
break;
default:
break;
diff --git a/LabelStoreMax/lib/app/models/customer_address.dart b/LabelStoreMax/lib/app/models/customer_address.dart
index 714f33e..c97ab94 100644
--- a/LabelStoreMax/lib/app/models/customer_address.dart
+++ b/LabelStoreMax/lib/app/models/customer_address.dart
@@ -11,14 +11,14 @@
import 'package:flutter_app/app/models/customer_country.dart';
class CustomerAddress {
- String firstName;
- String lastName;
- String addressLine;
- String city;
- String postalCode;
- String emailAddress;
- String phoneNumber;
- CustomerCountry customerCountry;
+ String? firstName;
+ String? lastName;
+ String? addressLine;
+ String? city;
+ String? postalCode;
+ String? emailAddress;
+ String? phoneNumber;
+ CustomerCountry? customerCountry;
CustomerAddress(
{this.firstName,
@@ -27,7 +27,7 @@ class CustomerAddress {
this.city,
this.postalCode,
this.emailAddress,
- this.phoneNumber,
+ this.phoneNumber,
this.customerCountry});
void initAddress() {
@@ -42,17 +42,17 @@ class CustomerAddress {
}
bool hasMissingFields() =>
- (firstName.isEmpty ||
- lastName.isEmpty ||
- addressLine.isEmpty ||
- city.isEmpty ||
- postalCode.isEmpty) ||
- (customerCountry.hasState() == true
+ (firstName!.isEmpty ||
+ lastName!.isEmpty ||
+ addressLine!.isEmpty ||
+ city!.isEmpty ||
+ postalCode!.isEmpty) ||
+ (customerCountry!.hasState() == true
? (customerCountry?.state?.name ?? "").isEmpty
: false);
String addressFull() {
- List tmpArrAddress = [];
+ List tmpArrAddress = [];
if (addressLine != null && addressLine != "") {
tmpArrAddress.add(addressLine);
}
@@ -66,13 +66,13 @@ class CustomerAddress {
tmpArrAddress.add(customerCountry?.state?.name);
}
if (customerCountry != null && customerCountry?.name != null) {
- tmpArrAddress.add(customerCountry.name);
+ tmpArrAddress.add(customerCountry!.name);
}
return tmpArrAddress.join(", ");
}
String nameFull() {
- List tmpArrName = [];
+ List tmpArrName = [];
if (firstName != "") {
tmpArrName.add(firstName);
}
@@ -102,15 +102,15 @@ class CustomerAddress {
data['address_line'] = addressLine;
data['city'] = city;
data['postal_code'] = postalCode;
- data['state'] = customerCountry.state;
- data['country'] = customerCountry.name;
+ data['state'] = customerCountry!.state;
+ data['country'] = customerCountry!.name;
if (phoneNumber != null && phoneNumber != "") {
data['phone_number'] = phoneNumber;
}
data['email_address'] = emailAddress;
data['customer_country'] = null;
if (customerCountry != null) {
- data['customer_country'] = customerCountry.toJson();
+ data['customer_country'] = customerCountry!.toJson();
}
return data;
}
diff --git a/LabelStoreMax/lib/app/models/customer_country.dart b/LabelStoreMax/lib/app/models/customer_country.dart
index 95bd807..c40557b 100644
--- a/LabelStoreMax/lib/app/models/customer_country.dart
+++ b/LabelStoreMax/lib/app/models/customer_country.dart
@@ -11,21 +11,22 @@
import 'package:flutter_app/app/models/default_shipping.dart';
class CustomerCountry {
- String countryCode;
- String name;
- DefaultShippingState state;
+ String? countryCode;
+ String? name;
+ DefaultShippingState? state;
CustomerCountry({this.countryCode, this.name, this.state});
- CustomerCountry.fromDefaultShipping({DefaultShipping defaultShipping}) {
+ CustomerCountry.fromDefaultShipping(
+ {required DefaultShipping defaultShipping}) {
countryCode = defaultShipping.code;
name = defaultShipping.country;
- if ((defaultShipping.states?.length ?? 0) == 1) {
+ if ((defaultShipping.states.length) == 1) {
state = defaultShipping.states.first;
}
}
- CustomerCountry.fromJson(Map json) {
+ CustomerCountry.fromJson(Map? json) {
if (json == null) {
return;
}
@@ -40,7 +41,7 @@ class CustomerCountry {
}
}
- bool hasState() => (state != null && state.name != null ? true : false);
+ bool hasState() => (state != null && state!.name != null ? true : false);
Map toJson() {
final Map data = {};
@@ -48,7 +49,7 @@ class CustomerCountry {
data['name'] = name;
data['state'] = null;
if (state != null) {
- data['state'] = state.toJson();
+ data['state'] = state!.toJson();
}
return data;
}
diff --git a/LabelStoreMax/lib/app/models/default_shipping.dart b/LabelStoreMax/lib/app/models/default_shipping.dart
index 4d8ab6b..820e8e8 100644
--- a/LabelStoreMax/lib/app/models/default_shipping.dart
+++ b/LabelStoreMax/lib/app/models/default_shipping.dart
@@ -7,22 +7,19 @@
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
-import 'package:flutter/cupertino.dart';
-
class DefaultShipping {
String code;
- String country;
+ String? country;
List states;
DefaultShipping(
- {@required this.code, @required this.country, @required this.states});
+ {required this.code, required this.country, required this.states});
}
class DefaultShippingState {
- String code;
- String name;
+ String? code;
+ String? name;
- DefaultShippingState({@required this.code, @required this.name});
+ DefaultShippingState({required this.code, required this.name});
Map toJson() {
final Map data = {};
diff --git a/LabelStoreMax/lib/app/models/payment_type.dart b/LabelStoreMax/lib/app/models/payment_type.dart
index dd30de7..50dcdb0 100644
--- a/LabelStoreMax/lib/app/models/payment_type.dart
+++ b/LabelStoreMax/lib/app/models/payment_type.dart
@@ -8,8 +8,6 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-import 'package:flutter/cupertino.dart';
-
class PaymentType {
int id;
String name;
@@ -18,9 +16,9 @@ class PaymentType {
Function pay;
PaymentType(
- {@required this.id,
- @required this.name,
- @required this.desc,
- @required this.assetImage,
- @required this.pay});
+ {required this.id,
+ required this.name,
+ required this.desc,
+ required this.assetImage,
+ required this.pay});
}
diff --git a/LabelStoreMax/lib/app/models/shipping_type.dart b/LabelStoreMax/lib/app/models/shipping_type.dart
index b3a3b68..004798b 100644
--- a/LabelStoreMax/lib/app/models/shipping_type.dart
+++ b/LabelStoreMax/lib/app/models/shipping_type.dart
@@ -7,22 +7,20 @@
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
-import 'package:flutter/cupertino.dart';
import 'package:flutter_app/bootstrap/helpers.dart';
import 'package:woosignal/models/response/shipping_method.dart';
class ShippingType {
- String methodId;
+ String? methodId;
String cost;
- String minimumValue;
+ String? minimumValue;
dynamic object;
ShippingType(
- {@required this.methodId,
+ {required this.methodId,
this.object,
- @required this.cost,
- @required this.minimumValue});
+ required this.cost,
+ required this.minimumValue});
Map toJson() => {
'methodId': methodId,
@@ -31,24 +29,24 @@ class ShippingType {
'minimumValue': minimumValue
};
- String getTotal({bool withFormatting = false}) {
+ String? getTotal({bool withFormatting = false}) {
if (object != null) {
switch (methodId) {
case "flat_rate":
- FlatRate flatRate = (object as FlatRate);
+ FlatRate? flatRate = (object as FlatRate?);
return (withFormatting == true
? formatStringCurrency(total: cost)
- : flatRate.cost);
+ : flatRate!.cost);
case "free_shipping":
- FreeShipping freeShipping = (object as FreeShipping);
+ FreeShipping? freeShipping = (object as FreeShipping?);
return (withFormatting == true
? formatStringCurrency(total: cost)
- : freeShipping.cost);
+ : freeShipping!.cost);
case "local_pickup":
- LocalPickup localPickup = (object as LocalPickup);
+ LocalPickup? localPickup = (object as LocalPickup?);
return (withFormatting == true
? formatStringCurrency(total: cost)
- : localPickup.cost);
+ : localPickup!.cost);
default:
return "0";
}
@@ -56,7 +54,7 @@ class ShippingType {
return "0";
}
- String getTitle() {
+ String? getTitle() {
if (object != null) {
switch (methodId) {
case "flat_rate":
@@ -75,7 +73,7 @@ class ShippingType {
return "";
}
- Map toShippingLineFee() {
+ Map? toShippingLineFee() {
if (object != null) {
Map tmpShippingLinesObj = {};
diff --git a/LabelStoreMax/lib/app/models/user.dart b/LabelStoreMax/lib/app/models/user.dart
index 25fdbfe..1a8d7ef 100644
--- a/LabelStoreMax/lib/app/models/user.dart
+++ b/LabelStoreMax/lib/app/models/user.dart
@@ -8,11 +8,11 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-import 'package:nylo_support/helpers/helper.dart';
+import 'package:nylo_framework/nylo_framework.dart';
class User extends Storable {
- String userId;
- String token;
+ String? userId;
+ String? token;
User();
User.fromUserAuthResponse({this.userId, this.token});
diff --git a/LabelStoreMax/lib/app/networking/api_service.dart b/LabelStoreMax/lib/app/networking/api_service.dart
index e391760..67e6b2d 100644
--- a/LabelStoreMax/lib/app/networking/api_service.dart
+++ b/LabelStoreMax/lib/app/networking/api_service.dart
@@ -1,11 +1,29 @@
-// Label StoreMax
-//
-// Created by Anthony Gordon.
-// 2022, WooSignal Ltd. All rights reserved.
-//
+import 'package:flutter/material.dart';
+import 'package:flutter_app/app/networking/dio/base_api_service.dart';
+import 'package:flutter_app/app/networking/dio/interceptors/logging_interceptor.dart';
+import 'package:nylo_framework/nylo_framework.dart';
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+/*
+|--------------------------------------------------------------------------
+| ApiService
+| -------------------------------------------------------------------------
+| Define your API endpoints
+| Learn more https://nylo.dev/docs/3.x/networking
+|--------------------------------------------------------------------------
+*/
-class ApiService {}
+class ApiService extends BaseApiService {
+ ApiService({BuildContext? buildContext}) : super(buildContext);
+
+ @override
+ String get baseUrl => getEnv('API_BASE_URL');
+
+ @override
+ final interceptors = {LoggingInterceptor: LoggingInterceptor()};
+
+ Future fetchTestData() async {
+ return await network(
+ request: (request) => request.get("/endpoint-path"),
+ );
+ }
+}
diff --git a/LabelStoreMax/lib/app/networking/dio/base_api_service.dart b/LabelStoreMax/lib/app/networking/dio/base_api_service.dart
new file mode 100644
index 0000000..70956ec
--- /dev/null
+++ b/LabelStoreMax/lib/app/networking/dio/base_api_service.dart
@@ -0,0 +1,16 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_app/app/networking/dio/interceptors/logging_interceptor.dart';
+import 'package:flutter_app/config/decoders.dart';
+import 'package:nylo_framework/networking/ny_base_networking.dart';
+
+class BaseApiService extends NyBaseApiService {
+ BaseApiService(BuildContext? context) : super(context);
+
+ /// Map decoders to modelDecoders
+ @override
+ final Map decoders = modelDecoders;
+
+ /// Default interceptors
+ @override
+ final interceptors = {LoggingInterceptor: LoggingInterceptor()};
+}
diff --git a/LabelStoreMax/lib/app/networking/dio/interceptors/bearer_auth_interceptor.dart b/LabelStoreMax/lib/app/networking/dio/interceptors/bearer_auth_interceptor.dart
new file mode 100644
index 0000000..9c8bda2
--- /dev/null
+++ b/LabelStoreMax/lib/app/networking/dio/interceptors/bearer_auth_interceptor.dart
@@ -0,0 +1,22 @@
+import 'package:nylo_framework/nylo_framework.dart';
+
+class BearerAuthInterceptor extends Interceptor {
+ @override
+ void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
+ String? userToken = Backpack.instance.read('user_token');
+ if (userToken != null) {
+ options.headers.addAll({"Authorization": "Bearer $userToken"});
+ }
+ return super.onRequest(options, handler);
+ }
+
+ @override
+ void onResponse(Response response, ResponseInterceptorHandler handler) {
+ handler.next(response);
+ }
+
+ @override
+ void onError(DioError err, ErrorInterceptorHandler handler) {
+ handler.next(err);
+ }
+}
diff --git a/LabelStoreMax/lib/app/networking/dio/interceptors/logging_interceptor.dart b/LabelStoreMax/lib/app/networking/dio/interceptors/logging_interceptor.dart
new file mode 100644
index 0000000..2aa5ffb
--- /dev/null
+++ b/LabelStoreMax/lib/app/networking/dio/interceptors/logging_interceptor.dart
@@ -0,0 +1,32 @@
+import 'dart:developer';
+import 'package:nylo_framework/nylo_framework.dart';
+
+class LoggingInterceptor extends Interceptor {
+ @override
+ void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
+ if (getEnv('APP_DEBUG') == true) {
+ print('REQUEST[${options.method}] => PATH: ${options.path}');
+ }
+ return super.onRequest(options, handler);
+ }
+
+ @override
+ void onResponse(Response response, ResponseInterceptorHandler handler) {
+ if (getEnv('APP_DEBUG') == true) {
+ print(
+ 'RESPONSE[${response.statusCode}] => PATH: ${response.requestOptions.path}');
+ print('DATA: ${response.requestOptions.path}');
+ log(response.data.toString());
+ }
+ handler.next(response);
+ }
+
+ @override
+ void onError(DioError err, ErrorInterceptorHandler handler) {
+ if (getEnv('APP_DEBUG') == true) {
+ print(
+ 'ERROR[${err.response?.statusCode}] => PATH: ${err.requestOptions.path}');
+ }
+ handler.next(err);
+ }
+}
diff --git a/LabelStoreMax/lib/app/providers/app_provider.dart b/LabelStoreMax/lib/app/providers/app_provider.dart
new file mode 100644
index 0000000..030afb5
--- /dev/null
+++ b/LabelStoreMax/lib/app/providers/app_provider.dart
@@ -0,0 +1,96 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_app/bootstrap/app_helper.dart';
+import 'package:flutter_app/bootstrap/helpers.dart';
+import 'package:nylo_framework/nylo_framework.dart';
+import 'package:flutter_app/config/localization.dart';
+import 'package:woosignal/models/response/woosignal_app.dart';
+import 'package:woosignal/woosignal.dart';
+import 'package:wp_json_api/wp_json_api.dart';
+
+class AppProvider implements NyProvider {
+ boot(Nylo nylo) async {
+ await SystemChrome.setPreferredOrientations([
+ DeviceOrientation.portraitUp,
+ ]);
+
+ await WooSignal.instance
+ .init(appKey: getEnv('APP_KEY'), debugMode: getEnv('APP_DEBUG'));
+
+ // Notifications
+ /// await Firebase.initializeApp(
+ /// options: DefaultFirebaseOptions.currentPlatform,
+ /// );
+ ///
+ /// FirebaseMessaging messaging = FirebaseMessaging.instance;
+ ///
+ /// NotificationSettings settings = await messaging.requestPermission(
+ /// alert: true,
+ /// announcement: false,
+ /// badge: true,
+ /// carPlay: false,
+ /// criticalAlert: false,
+ /// provisional: false,
+ /// sound: true,
+ /// );
+ ///
+ /// if (settings.authorizationStatus == AuthorizationStatus.authorized) {
+ /// String token = await messaging.getToken();
+ /// WooSignal.instance.setFcmToken(token);
+ /// }
+
+ AppHelper.instance.appConfig = WooSignalApp();
+ AppHelper.instance.appConfig!.themeFont = "Poppins";
+ AppHelper.instance.appConfig!.themeColors = {
+ 'light': {
+ 'background': '0xFFFFFFFF',
+ 'primary_text': '0xFF000000',
+ 'button_background': '0xFF529cda',
+ 'button_text': '0xFFFFFFFF',
+ 'app_bar_background': '0xFFFFFFFF',
+ 'app_bar_text': '0xFF3a3d40',
+ },
+ 'dark': {
+ 'background': '0xFF212121',
+ 'primary_text': '0xFFE1E1E1',
+ 'button_background': '0xFFFFFFFF',
+ 'button_text': '0xFF232c33',
+ 'app_bar_background': '0xFF2C2C2C',
+ 'app_bar_text': '0xFFFFFFFF',
+ }
+ };
+
+ // WooSignal Setup
+ WooSignalApp? wooSignalApp = await (appWooSignal((api) => api.getApp()));
+ Locale locale = Locale('en');
+
+ if (wooSignalApp != null) {
+ AppHelper.instance.appConfig = wooSignalApp;
+
+ if (wooSignalApp.wpLoginEnabled == 1) {
+ WPJsonAPI.instance.initWith(
+ baseUrl: wooSignalApp.wpLoginBaseUrl!,
+ shouldDebug: getEnv('APP_DEBUG'),
+ wpJsonPath: wooSignalApp.wpLoginWpApiPath!,
+ );
+ }
+
+ if (getEnv('DEFAULT_LOCALE', defaultValue: null) == null &&
+ wooSignalApp.locale != null) {
+ locale = Locale(wooSignalApp.locale!);
+ } else {
+ locale = Locale(envVal('DEFAULT_LOCALE', defaultValue: 'en'));
+ }
+ }
+
+ /// NyLocalization
+ await NyLocalization.instance.init(
+ localeType: localeType,
+ languageCode: locale.languageCode,
+ languagesList: languagesList,
+ assetsDirectory: assetsDirectory,
+ valuesAsMap: valuesAsMap);
+
+ return nylo;
+ }
+}
diff --git a/LabelStoreMax/lib/app/providers/cash_on_delivery.dart b/LabelStoreMax/lib/app/providers/cash_on_delivery.dart
index 4015f41..18f0a58 100644
--- a/LabelStoreMax/lib/app/providers/cash_on_delivery.dart
+++ b/LabelStoreMax/lib/app/providers/cash_on_delivery.dart
@@ -21,11 +21,11 @@ import 'package:woosignal/models/response/order.dart';
import 'package:woosignal/models/response/tax_rate.dart';
cashOnDeliveryPay(context,
- {@required CheckoutConfirmationPageState state, TaxRate taxRate}) async {
+ {required CheckoutConfirmationPageState state, TaxRate? taxRate}) async {
try {
OrderWC orderWC = await buildOrderWC(taxRate: taxRate, markPaid: false);
- Order order = await appWooSignal((api) => api.createOrder(orderWC));
+ Order? order = await (appWooSignal((api) => api.createOrder(orderWC)));
if (order != null) {
Navigator.pushNamed(context, "/checkout-status", arguments: order);
diff --git a/LabelStoreMax/lib/app/providers/event_provider.dart b/LabelStoreMax/lib/app/providers/event_provider.dart
new file mode 100644
index 0000000..ea35d13
--- /dev/null
+++ b/LabelStoreMax/lib/app/providers/event_provider.dart
@@ -0,0 +1,11 @@
+import 'package:flutter_app/config/events.dart';
+import 'package:nylo_framework/nylo_framework.dart';
+
+class EventProvider implements NyProvider {
+ @override
+ boot(Nylo nylo) async {
+ nylo.addEvents(events);
+
+ return nylo;
+ }
+}
diff --git a/LabelStoreMax/lib/app/providers/example_pay.dart b/LabelStoreMax/lib/app/providers/example_pay.dart
index 3fdbe35..61c81a2 100644
--- a/LabelStoreMax/lib/app/providers/example_pay.dart
+++ b/LabelStoreMax/lib/app/providers/example_pay.dart
@@ -33,7 +33,7 @@ import 'package:woosignal/models/response/tax_rate.dart';
// AS THE PAY METHOD
examplePay(context,
- {@required CheckoutConfirmationPageState state, TaxRate taxRate}) async {
+ {required CheckoutConfirmationPageState state, TaxRate? taxRate}) async {
// HANDLE YOUR PAYMENT INTEGRATION HERE
// ...
// ...
@@ -44,7 +44,7 @@ examplePay(context,
OrderWC orderWC = await buildOrderWC(taxRate: taxRate, markPaid: true);
// CREATES ORDER IN WOOCOMMERCE
- Order order = await appWooSignal((api) => api.createOrder(orderWC));
+ Order? order = await (appWooSignal((api) => api.createOrder(orderWC)));
// CHECK IF ORDER IS NULL
if (order != null) {
diff --git a/LabelStoreMax/lib/app/providers/paypal_pay.dart b/LabelStoreMax/lib/app/providers/paypal_pay.dart
index f19027f..57664e8 100644
--- a/LabelStoreMax/lib/app/providers/paypal_pay.dart
+++ b/LabelStoreMax/lib/app/providers/paypal_pay.dart
@@ -23,7 +23,7 @@ import 'package:woosignal/models/response/order.dart';
import 'package:woosignal/models/response/tax_rate.dart';
payPalPay(context,
- {@required CheckoutConfirmationPageState state, TaxRate taxRate}) async {
+ {required CheckoutConfirmationPageState state, TaxRate? taxRate}) async {
await checkout(taxRate, (total, billingDetails, cart) async {
List cartLineItems = await cart.getCart();
String description = await cart.cartShortDesc();
@@ -35,7 +35,7 @@ payPalPay(context,
description: description,
amount: total,
cartLineItems: cartLineItems))).then((value) async {
- if (!(value is Map)) {
+ if (value is! Map) {
showToastNotification(
context,
title: trans("Payment Cancelled"),
@@ -48,7 +48,7 @@ payPalPay(context,
state.reloadState(showLoader: true);
if (value.containsKey("status") && value["status"] == "success") {
OrderWC orderWC = await buildOrderWC(taxRate: taxRate, markPaid: true);
- Order order = await appWooSignal((api) => api.createOrder(orderWC));
+ Order? order = await (appWooSignal((api) => api.createOrder(orderWC)));
if (order == null) {
showToastNotification(
diff --git a/LabelStoreMax/lib/app/providers/razorpay_provider.dart b/LabelStoreMax/lib/app/providers/razorpay_provider.dart
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/LabelStoreMax/lib/app/providers/razorpay_provider.dart
@@ -0,0 +1 @@
+
diff --git a/LabelStoreMax/lib/app/providers/route_provider.dart b/LabelStoreMax/lib/app/providers/route_provider.dart
new file mode 100644
index 0000000..d2702dd
--- /dev/null
+++ b/LabelStoreMax/lib/app/providers/route_provider.dart
@@ -0,0 +1,10 @@
+import 'package:flutter_app/routes/router.dart';
+import 'package:nylo_framework/nylo_framework.dart';
+
+class RouteProvider implements NyProvider {
+ boot(Nylo nylo) async {
+ nylo.addRouter(appRouter());
+
+ return nylo;
+ }
+}
diff --git a/LabelStoreMax/lib/app/providers/stripe_pay.dart b/LabelStoreMax/lib/app/providers/stripe_pay.dart
index 0740f98..61cdf75 100644
--- a/LabelStoreMax/lib/app/providers/stripe_pay.dart
+++ b/LabelStoreMax/lib/app/providers/stripe_pay.dart
@@ -24,16 +24,16 @@ import 'package:woosignal/models/response/tax_rate.dart';
import 'package:woosignal/models/response/woosignal_app.dart';
stripePay(context,
- {@required CheckoutConfirmationPageState state, TaxRate taxRate}) async {
- WooSignalApp wooSignalApp = AppHelper.instance.appConfig;
+ {required CheckoutConfirmationPageState state, TaxRate? taxRate}) async {
+ WooSignalApp? wooSignalApp = AppHelper.instance.appConfig;
bool liveMode = getEnv('STRIPE_LIVE_MODE') == null
- ? !wooSignalApp.stripeLiveMode
+ ? !wooSignalApp!.stripeLiveMode!
: getEnv('STRIPE_LIVE_MODE', defaultValue: false);
// CONFIGURE STRIPE
Stripe.stripeAccountId =
- getEnv('STRIPE_ACCOUNT') ?? wooSignalApp.stripeAccount;
+ getEnv('STRIPE_ACCOUNT') ?? wooSignalApp!.stripeAccount;
Stripe.publishableKey = liveMode
? "pk_live_IyS4Vt86L49jITSfaUShumzi"
@@ -51,10 +51,10 @@ stripePay(context,
// // CHECKOUT HELPER
await checkout(taxRate, (total, billingDetails, cart) async {
Map address = {
- "name": billingDetails.billingAddress.nameFull(),
- "line1": billingDetails.shippingAddress.addressLine,
- "city": billingDetails.shippingAddress.city,
- "postal_code": billingDetails.shippingAddress.postalCode,
+ "name": billingDetails!.billingAddress!.nameFull(),
+ "line1": billingDetails.shippingAddress!.addressLine,
+ "city": billingDetails.shippingAddress!.city,
+ "postal_code": billingDetails.shippingAddress!.postalCode,
"country": (billingDetails.shippingAddress?.customerCountry?.name ?? "")
};
@@ -62,7 +62,7 @@ stripePay(context,
rsp = await appWooSignal((api) => api.stripePaymentIntent(
amount: total,
- email: billingDetails.billingAddress.emailAddress,
+ email: billingDetails.billingAddress!.emailAddress,
desc: cartShortDesc,
shipping: address,
));
@@ -87,7 +87,7 @@ stripePay(context,
: ThemeMode.dark,
testEnv: liveMode,
merchantCountryCode: envVal('STRIPE_COUNTRY_CODE',
- defaultValue: wooSignalApp.stripeCountryCode),
+ defaultValue: wooSignalApp!.stripeCountryCode),
merchantDisplayName:
envVal('APP_NAME', defaultValue: wooSignalApp.appName),
paymentIntentClientSecret: rsp['client_secret'],
@@ -98,7 +98,7 @@ stripePay(context,
state.reloadState(showLoader: true);
OrderWC orderWC = await buildOrderWC(taxRate: taxRate);
- Order order = await appWooSignal((api) => api.createOrder(orderWC));
+ Order? order = await (appWooSignal((api) => api.createOrder(orderWC)));
if (order == null) {
showToastNotification(
@@ -113,12 +113,12 @@ stripePay(context,
Navigator.pushNamed(context, "/checkout-status", arguments: order);
} on StripeException catch (e) {
if (getEnv('APP_DEBUG', defaultValue: true)) {
- NyLogger.error(e.error.message);
+ NyLogger.error(e.error.message!);
}
showToastNotification(
context,
title: trans("Oops!"),
- description: e.error.localizedMessage,
+ description: e.error.localizedMessage!,
icon: Icons.payment,
style: ToastNotificationStyleType.WARNING,
);
diff --git a/LabelStoreMax/lib/bootstrap/app.dart b/LabelStoreMax/lib/bootstrap/app.dart
index d3314f9..25a1181 100644
--- a/LabelStoreMax/lib/bootstrap/app.dart
+++ b/LabelStoreMax/lib/bootstrap/app.dart
@@ -1,42 +1,42 @@
import 'package:flutter/material.dart';
-import 'package:flutter_app/config/app_theme.dart';
+import 'package:flutter_app/config/theme.dart';
import 'package:nylo_framework/nylo_framework.dart';
// ignore: must_be_immutable
class AppBuild extends StatelessWidget {
- String initialRoute;
- ThemeData themeData;
- ThemeData darkTheme;
- ThemeData lightTheme;
- Locale locale;
- String title;
+ String? initialRoute;
+ ThemeData? themeData;
+ ThemeData? darkTheme;
+ ThemeData? lightTheme;
+ Locale? locale;
+ String? title;
bool debugShowCheckedModeBanner;
bool debugShowMaterialGrid;
bool showPerformanceOverlay;
bool checkerboardRasterCacheImages;
bool checkerboardOffscreenLayers;
bool showSemanticsDebugger;
- Map shortcuts;
- Map> actions;
+ Map? shortcuts;
+ Map>? actions;
List supportedLocales;
ThemeMode themeMode;
- Color color;
- GenerateAppTitle onGenerateTitle;
- TransitionBuilder builder;
+ Color? color;
+ GenerateAppTitle? onGenerateTitle;
+ TransitionBuilder? builder;
List navigatorObservers;
- RouteFactory onUnknownRoute;
- InitialRouteListFactory onGenerateInitialRoutes;
- GlobalKey navigatorKey;
+ RouteFactory? onUnknownRoute;
+ InitialRouteListFactory? onGenerateInitialRoutes;
+ GlobalKey? navigatorKey;
- Route Function(RouteSettings settings) onGenerateRoute;
+ Route? Function(RouteSettings settings) onGenerateRoute;
AppBuild({
- Key key,
+ Key? key,
this.initialRoute,
this.title,
this.locale,
this.themeData,
- @required this.onGenerateRoute,
+ required this.onGenerateRoute,
this.navigatorKey,
this.onGenerateInitialRoutes,
this.onUnknownRoute,
@@ -64,7 +64,7 @@ class AppBuild extends StatelessWidget {
child: ThemeProvider(
themes: appThemes
.map((appTheme) => appTheme.toAppTheme(
- defaultTheme: appTheme.theme.brightness == Brightness.light
+ defaultTheme: appTheme.theme!.brightness == Brightness.light
? lightTheme
: darkTheme))
.toList(),
@@ -96,13 +96,12 @@ class AppBuild extends StatelessWidget {
darkTheme: darkTheme ?? ThemeConfig.dark().theme,
theme: themeData ?? ThemeProvider.themeOf(context).data,
localeResolutionCallback:
- (Locale locale, Iterable supportedLocales) {
+ (Locale? locale, Iterable supportedLocales) {
return locale;
},
localizationsDelegates: NyLocalization.instance.delegates,
locale: NyLocalization.instance.locale,
- supportedLocales:
- supportedLocales ?? NyLocalization.instance.locals(),
+ supportedLocales: supportedLocales,
),
),
),
diff --git a/LabelStoreMax/lib/bootstrap/app_helper.dart b/LabelStoreMax/lib/bootstrap/app_helper.dart
index 92474df..2c88fe2 100644
--- a/LabelStoreMax/lib/bootstrap/app_helper.dart
+++ b/LabelStoreMax/lib/bootstrap/app_helper.dart
@@ -15,5 +15,5 @@ class AppHelper {
static final AppHelper instance = AppHelper._privateConstructor();
- WooSignalApp appConfig;
+ WooSignalApp? appConfig;
}
diff --git a/LabelStoreMax/lib/bootstrap/base_theme_config.dart b/LabelStoreMax/lib/bootstrap/base_theme_config.dart
index 1c700a8..3544964 100644
--- a/LabelStoreMax/lib/bootstrap/base_theme_config.dart
+++ b/LabelStoreMax/lib/bootstrap/base_theme_config.dart
@@ -3,10 +3,10 @@ import 'package:flutter_app/resources/themes/styles/base_styles.dart';
import 'package:nylo_framework/nylo_framework.dart';
class BaseThemeConfig {
- final String id;
- final String description;
- final ThemeData theme;
- final BaseColorStyles colors;
+ final String? id;
+ final String? description;
+ final ThemeData? theme;
+ final BaseColorStyles? colors;
final dynamic meta;
BaseThemeConfig(
@@ -16,9 +16,9 @@ class BaseThemeConfig {
this.colors,
this.meta = const {}});
- AppTheme toAppTheme({ThemeData defaultTheme}) => AppTheme(
- id: id,
- data: defaultTheme ?? theme,
- description: description,
+ AppTheme toAppTheme({ThemeData? defaultTheme}) => AppTheme(
+ id: id!,
+ data: defaultTheme ?? theme!,
+ description: description!,
);
}
diff --git a/LabelStoreMax/lib/bootstrap/boot.dart b/LabelStoreMax/lib/bootstrap/boot.dart
index 7368729..634f38d 100644
--- a/LabelStoreMax/lib/bootstrap/boot.dart
+++ b/LabelStoreMax/lib/bootstrap/boot.dart
@@ -1,96 +1,12 @@
// import 'package:firebase_core/firebase_core.dart';
// import 'package:firebase_messaging/firebase_messaging.dart';
// import 'package:flutter_app/firebase_options.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:flutter_app/bootstrap/app_helper.dart';
-import 'package:flutter_app/bootstrap/helpers.dart';
-import 'package:flutter_app/config/app_localization.dart';
-import 'package:nylo_framework/nylo_framework.dart';
-import 'package:woosignal/models/response/woosignal_app.dart';
-import 'package:woosignal/woosignal.dart';
-import 'package:wp_json_api/wp_json_api.dart';
/// boot application
-Future boot() async {
- await SystemChrome.setPreferredOrientations([
- DeviceOrientation.portraitUp,
- ]);
-
- await WooSignal.instance
- .init(appKey: getEnv('APP_KEY'), debugMode: getEnv('APP_DEBUG'));
-
- // Notifications
- /// await Firebase.initializeApp(
- /// options: DefaultFirebaseOptions.currentPlatform,
- /// );
- ///
- /// FirebaseMessaging messaging = FirebaseMessaging.instance;
- ///
- /// NotificationSettings settings = await messaging.requestPermission(
- /// alert: true,
- /// announcement: false,
- /// badge: true,
- /// carPlay: false,
- /// criticalAlert: false,
- /// provisional: false,
- /// sound: true,
- /// );
- ///
- /// if (settings.authorizationStatus == AuthorizationStatus.authorized) {
- /// String token = await messaging.getToken();
- /// WooSignal.instance.setFcmToken(token);
- /// }
-
- AppHelper?.instance?.appConfig = WooSignalApp();
- AppHelper.instance.appConfig.themeFont = "Poppins";
- AppHelper.instance.appConfig.themeColors = {
- 'light': {
- 'background': '0xFFFFFFFF',
- 'primary_text': '0xFF000000',
- 'button_background': '0xFF529cda',
- 'button_text': '0xFFFFFFFF',
- 'app_bar_background': '0xFFFFFFFF',
- 'app_bar_text': '0xFF3a3d40',
- },
- 'dark': {
- 'background': '0xFF212121',
- 'primary_text': '0xFFE1E1E1',
- 'button_background': '0xFFFFFFFF',
- 'button_text': '0xFF232c33',
- 'app_bar_background': '0xFF2C2C2C',
- 'app_bar_text': '0xFFFFFFFF',
- }
- };
-
- // WooSignal Setup
- WooSignalApp wooSignalApp = await appWooSignal((api) => api.getApp());
- Locale locale = Locale('en');
-
- if (wooSignalApp != null) {
- AppHelper.instance.appConfig = wooSignalApp;
-
- if (wooSignalApp.wpLoginEnabled == 1) {
- WPJsonAPI.instance.initWith(
- baseUrl: wooSignalApp.wpLoginBaseUrl,
- shouldDebug: getEnv('APP_DEBUG'),
- wpJsonPath: wooSignalApp.wpLoginWpApiPath,
- );
- }
-
- if (getEnv('DEFAULT_LOCALE', defaultValue: null) == null &&
- wooSignalApp.locale != null) {
- locale = Locale(wooSignalApp.locale);
- } else {
- locale = Locale(envVal('DEFAULT_LOCALE', defaultValue: 'en'));
- }
- }
+import 'package:flutter_app/config/providers.dart';
+import 'package:nylo_framework/nylo_framework.dart';
- /// NyLocalization
- await NyLocalization.instance.init(
- localeType: localeType,
- languageCode: locale.languageCode,
- languagesList: languagesList,
- assetsDirectory: assetsDirectory,
- valuesAsMap: valuesAsMap);
+class Boot {
+ static Future nylo() async => await bootApplication(providers);
+ static Future finished(Nylo nylo) async => await bootFinished(nylo);
}
diff --git a/LabelStoreMax/lib/bootstrap/data/order_wc.dart b/LabelStoreMax/lib/bootstrap/data/order_wc.dart
index a453c06..ad8a192 100644
--- a/LabelStoreMax/lib/bootstrap/data/order_wc.dart
+++ b/LabelStoreMax/lib/bootstrap/data/order_wc.dart
@@ -20,12 +20,12 @@ import 'package:woosignal/models/payload/order_wc.dart';
import 'package:woosignal/models/response/tax_rate.dart';
import 'package:woosignal/models/response/woosignal_app.dart';
-Future buildOrderWC({TaxRate taxRate, bool markPaid = true}) async {
+Future buildOrderWC({TaxRate? taxRate, bool markPaid = true}) async {
CheckoutSession checkoutSession = CheckoutSession.getInstance;
OrderWC orderWC = OrderWC();
- WooSignalApp wooSignalApp = AppHelper.instance.appConfig;
+ WooSignalApp wooSignalApp = AppHelper.instance.appConfig!;
- String paymentMethodName = checkoutSession.paymentType.name ?? "";
+ String paymentMethodName = checkoutSession.paymentType!.name;
orderWC.paymentMethod = Platform.isAndroid
? "$paymentMethodName - Android App"
@@ -35,9 +35,10 @@ Future buildOrderWC({TaxRate taxRate, bool markPaid = true}) async {
orderWC.setPaid = markPaid;
orderWC.status = "pending";
- orderWC.currency = wooSignalApp.currencyMeta.code.toUpperCase();
- orderWC.customerId =
- (wooSignalApp.wpLoginEnabled == 1) ? int.parse(await readUserId()) : 0;
+ orderWC.currency = wooSignalApp.currencyMeta!.code!.toUpperCase();
+ orderWC.customerId = (wooSignalApp.wpLoginEnabled == 1)
+ ? int.parse(await (readUserId()) ?? "0")
+ : 0;
List lineItems = [];
List cartItems = await Cart.getInstance.getCart();
@@ -56,49 +57,50 @@ Future buildOrderWC({TaxRate taxRate, bool markPaid = true}) async {
orderWC.lineItems = lineItems;
- BillingDetails billingDetails = checkoutSession.billingDetails;
+ BillingDetails billingDetails = checkoutSession.billingDetails!;
Billing billing = Billing();
- billing.firstName = billingDetails.billingAddress.firstName;
- billing.lastName = billingDetails.billingAddress.lastName;
- billing.address1 = billingDetails.billingAddress.addressLine;
- billing.city = billingDetails.billingAddress.city;
- billing.postcode = billingDetails.billingAddress.postalCode;
- billing.email = billingDetails.billingAddress.emailAddress;
- if (billingDetails.billingAddress.phoneNumber != "") {
- billing.phone = billingDetails.billingAddress.phoneNumber;
+ billing.firstName = billingDetails.billingAddress!.firstName;
+ billing.lastName = billingDetails.billingAddress!.lastName;
+ billing.address1 = billingDetails.billingAddress!.addressLine;
+ billing.city = billingDetails.billingAddress!.city;
+ billing.postcode = billingDetails.billingAddress!.postalCode;
+ billing.email = billingDetails.billingAddress!.emailAddress;
+ if (billingDetails.billingAddress!.phoneNumber != "") {
+ billing.phone = billingDetails.billingAddress!.phoneNumber;
}
- if (billingDetails.billingAddress.customerCountry.hasState()) {
- billing.state = billingDetails.billingAddress.customerCountry.state.name;
+ if (billingDetails.billingAddress!.customerCountry!.hasState()) {
+ billing.state = billingDetails.billingAddress!.customerCountry!.state!.name;
}
- billing.country = billingDetails.billingAddress.customerCountry.name;
+ billing.country = billingDetails.billingAddress!.customerCountry!.name;
orderWC.billing = billing;
Shipping shipping = Shipping();
- shipping.firstName = billingDetails.shippingAddress.firstName;
- shipping.lastName = billingDetails.shippingAddress.lastName;
- shipping.address1 = billingDetails.shippingAddress.addressLine;
- shipping.city = billingDetails.shippingAddress.city;
- shipping.postcode = billingDetails.shippingAddress.postalCode;
- if (billingDetails.shippingAddress.customerCountry.hasState()) {
- billing.state = billingDetails.shippingAddress.customerCountry.state.name;
+ shipping.firstName = billingDetails.shippingAddress!.firstName;
+ shipping.lastName = billingDetails.shippingAddress!.lastName;
+ shipping.address1 = billingDetails.shippingAddress!.addressLine;
+ shipping.city = billingDetails.shippingAddress!.city;
+ shipping.postcode = billingDetails.shippingAddress!.postalCode;
+ if (billingDetails.shippingAddress!.customerCountry!.hasState()) {
+ billing.state =
+ billingDetails.shippingAddress!.customerCountry!.state!.name;
}
- billing.country = billingDetails.shippingAddress.customerCountry.name;
+ billing.country = billingDetails.shippingAddress!.customerCountry!.name;
orderWC.shipping = shipping;
orderWC.shippingLines = [];
if (wooSignalApp.disableShipping != 1) {
- Map shippingLineFeeObj =
- checkoutSession.shippingType.toShippingLineFee();
+ Map? shippingLineFeeObj =
+ checkoutSession.shippingType!.toShippingLineFee();
if (shippingLineFeeObj != null) {
ShippingLines shippingLine = ShippingLines();
shippingLine.methodId = shippingLineFeeObj['method_id'];
shippingLine.methodTitle = shippingLineFeeObj['method_title'];
shippingLine.total = shippingLineFeeObj['total'];
- orderWC.shippingLines.add(shippingLine);
+ orderWC.shippingLines!.add(shippingLine);
}
}
@@ -109,13 +111,13 @@ Future buildOrderWC({TaxRate taxRate, bool markPaid = true}) async {
feeLines.total = await Cart.getInstance.taxAmount(taxRate);
feeLines.taxClass = "";
feeLines.taxStatus = "taxable";
- orderWC.feeLines.add(feeLines);
+ orderWC.feeLines!.add(feeLines);
}
if (checkoutSession.coupon != null) {
orderWC.couponLines = [];
- CouponLines couponLine = CouponLines(code: checkoutSession.coupon.code);
- orderWC.couponLines.add(couponLine);
+ CouponLines couponLine = CouponLines(code: checkoutSession.coupon!.code);
+ orderWC.couponLines!.add(couponLine);
}
return orderWC;
diff --git a/LabelStoreMax/lib/bootstrap/enums/wishlist_action_enums.dart b/LabelStoreMax/lib/bootstrap/enums/wishlist_action_enums.dart
index 2a54d73..934e4fc 100644
--- a/LabelStoreMax/lib/bootstrap/enums/wishlist_action_enums.dart
+++ b/LabelStoreMax/lib/bootstrap/enums/wishlist_action_enums.dart
@@ -8,8 +8,4 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
-enum WishlistAction {
- add,
- remove
-}
\ No newline at end of file
+enum WishlistAction { add, remove }
diff --git a/LabelStoreMax/lib/bootstrap/helpers.dart b/LabelStoreMax/lib/bootstrap/helpers.dart
index f0fc71e..e936b21 100644
--- a/LabelStoreMax/lib/bootstrap/helpers.dart
+++ b/LabelStoreMax/lib/bootstrap/helpers.dart
@@ -9,6 +9,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import 'dart:convert';
+import 'package:collection/collection.dart' show IterableExtension;
import 'package:flutter/cupertino.dart';
import 'package:flutter_app/app/models/billing_details.dart';
import 'package:flutter_app/app/models/cart.dart';
@@ -20,9 +21,11 @@ import 'package:flutter_app/app/models/user.dart';
import 'package:flutter_app/bootstrap/app_helper.dart';
import 'package:flutter_app/bootstrap/enums/symbol_position_enums.dart';
import 'package:flutter_app/bootstrap/shared_pref/shared_key.dart';
-import 'package:flutter_app/config/app_currency.dart';
-import 'package:flutter_app/config/app_payment_gateways.dart';
-import 'package:flutter_app/config/app_theme.dart';
+import 'package:flutter_app/config/currency.dart';
+import 'package:flutter_app/config/decoders.dart';
+import 'package:flutter_app/config/events.dart';
+import 'package:flutter_app/config/payment_gateways.dart';
+import 'package:flutter_app/config/theme.dart';
import 'package:flutter_app/resources/themes/styles/base_styles.dart';
import 'package:flutter_app/resources/widgets/no_results_for_products_widget.dart';
import 'package:flutter_app/resources/widgets/woosignal_ui.dart';
@@ -34,15 +37,14 @@ import 'package:flutter_web_browser/flutter_web_browser.dart';
import 'package:math_expressions/math_expressions.dart';
import 'package:money_formatter/money_formatter.dart';
import 'package:nylo_framework/nylo_framework.dart';
-import 'package:platform_alert_dialog/platform_alert_dialog.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:status_alert/status_alert.dart';
import 'package:woosignal/models/response/products.dart';
import 'package:woosignal/models/response/tax_rate.dart';
import 'package:woosignal/woosignal.dart';
-Future getUser() async =>
- (await NyStorage.read(SharedKey.authUser, model: User()));
+Future getUser() async =>
+ (await (NyStorage.read(SharedKey.authUser, model: User())));
Future appWooSignal(Function(WooSignal) api) async {
return await api(WooSignal.instance);
@@ -50,7 +52,7 @@ Future appWooSignal(Function(WooSignal) api) async {
/// helper to find correct color from the [context].
class ThemeColor {
- static BaseColorStyles get(BuildContext context) {
+ static BaseColorStyles? get(BuildContext context) {
return ((Theme.of(context).brightness == Brightness.light)
? ThemeConfig.light().colors
: ThemeConfig.dark().colors);
@@ -60,39 +62,37 @@ class ThemeColor {
/// helper to set colors on TextStyle
extension ColorsHelper on TextStyle {
TextStyle setColor(
- BuildContext context, Color Function(BaseColorStyles color) newColor) {
+ BuildContext context, Color Function(BaseColorStyles? color) newColor) {
return copyWith(color: newColor(ThemeColor.get(context)));
}
}
-List getPaymentTypes() {
- List paymentTypes = [];
- for (var appPaymentGateway in app_payment_gateways) {
+List getPaymentTypes() {
+ List paymentTypes = [];
+ for (var appPaymentGateway in appPaymentGateways) {
if (paymentTypes.firstWhere(
- (paymentType) => paymentType.name != appPaymentGateway,
+ (paymentType) => paymentType!.name != appPaymentGateway,
orElse: () => null) ==
null) {
- paymentTypes.add(paymentTypeList.firstWhere(
- (paymentTypeList) => paymentTypeList.name == appPaymentGateway,
- orElse: () => null));
+ paymentTypes.add(paymentTypeList.firstWhereOrNull(
+ (paymentTypeList) => paymentTypeList.name == appPaymentGateway));
}
}
- if (!app_payment_gateways.contains('Stripe') &&
- AppHelper.instance.appConfig.stripeEnabled == true) {
+ if (!appPaymentGateways.contains('Stripe') &&
+ AppHelper.instance.appConfig!.stripeEnabled == true) {
paymentTypes.add(paymentTypeList
- .firstWhere((element) => element.name == "Stripe", orElse: () => null));
+ .firstWhereOrNull((element) => element.name == "Stripe"));
}
- if (!app_payment_gateways.contains('PayPal') &&
- AppHelper.instance.appConfig.paypalEnabled == true) {
+ if (!appPaymentGateways.contains('PayPal') &&
+ AppHelper.instance.appConfig!.paypalEnabled == true) {
paymentTypes.add(paymentTypeList
- .firstWhere((element) => element.name == "PayPal", orElse: () => null));
+ .firstWhereOrNull((element) => element.name == "PayPal"));
}
- if (!app_payment_gateways.contains('CashOnDelivery') &&
- AppHelper.instance.appConfig.codEnabled == true) {
- paymentTypes.add(paymentTypeList.firstWhere(
- (element) => element.name == "CashOnDelivery",
- orElse: () => null));
+ if (!appPaymentGateways.contains('CashOnDelivery') &&
+ AppHelper.instance.appConfig!.codEnabled == true) {
+ paymentTypes.add(paymentTypeList
+ .firstWhereOrNull((element) => element.name == "CashOnDelivery"));
}
return paymentTypes.where((v) => v != null).toList();
@@ -102,11 +102,11 @@ dynamic envVal(String envVal, {dynamic defaultValue}) =>
(getEnv(envVal) ?? defaultValue);
PaymentType addPayment(
- {@required int id,
- @required String name,
- @required String desc,
- @required String assetImage,
- @required Function pay}) =>
+ {required int id,
+ required String name,
+ required String desc,
+ required String assetImage,
+ required Function pay}) =>
PaymentType(
id: id,
name: name,
@@ -116,7 +116,10 @@ PaymentType addPayment(
);
showStatusAlert(context,
- {@required String title, String subtitle, IconData icon, int duration}) {
+ {required String title,
+ required String subtitle,
+ IconData? icon,
+ int? duration}) {
StatusAlert.show(
context,
duration: Duration(seconds: duration ?? 2),
@@ -126,31 +129,31 @@ showStatusAlert(context,
);
}
-String parseHtmlString(String htmlString) {
+String parseHtmlString(String? htmlString) {
var document = parse(htmlString);
- return parse(document.body.text).documentElement.text;
+ return parse(document.body!.text).documentElement!.text;
}
String moneyFormatter(double amount) {
MoneyFormatter fmf = MoneyFormatter(
amount: amount,
settings: MoneyFormatterSettings(
- symbol: AppHelper.instance.appConfig.currencyMeta.symbolNative,
+ symbol: AppHelper.instance.appConfig!.currencyMeta!.symbolNative,
),
);
- if (app_currency_symbol_position == SymbolPositionType.left) {
+ if (appCurrencySymbolPosition == SymbolPositionType.left) {
return fmf.output.symbolOnLeft;
- } else if (app_currency_symbol_position == SymbolPositionType.right) {
+ } else if (appCurrencySymbolPosition == SymbolPositionType.right) {
return fmf.output.symbolOnRight;
}
return fmf.output.symbolOnLeft;
}
-String formatDoubleCurrency({@required double total}) {
+String formatDoubleCurrency({required double total}) {
return moneyFormatter(total);
}
-String formatStringCurrency({@required String total}) {
+String formatStringCurrency({required String? total}) {
double tmpVal = 0;
if (total != null && total != "") {
tmpVal = parseWcPrice(total);
@@ -159,20 +162,24 @@ String formatStringCurrency({@required String total}) {
}
String workoutSaleDiscount(
- {@required String salePrice, @required String priceBefore}) {
+ {required String? salePrice, required String? priceBefore}) {
double dSalePrice = parseWcPrice(salePrice);
double dPriceBefore = parseWcPrice(priceBefore);
return ((dPriceBefore - dSalePrice) * (100 / dPriceBefore))
.toStringAsFixed(0);
}
-openBrowserTab({@required String url}) async {
+openBrowserTab({required String url}) async {
await FlutterWebBrowser.openWebPage(
- url: url,
- customTabsOptions: CustomTabsOptions(toolbarColor: Colors.white70));
+ url: url,
+ customTabsOptions: CustomTabsOptions(
+ defaultColorSchemeParams:
+ CustomTabsColorSchemeParams(toolbarColor: Colors.white70),
+ ),
+ );
}
-bool isNumeric(String str) {
+bool isNumeric(String? str) {
if (str == null) {
return false;
}
@@ -180,18 +187,18 @@ bool isNumeric(String str) {
}
checkout(
- TaxRate taxRate,
- Function(String total, BillingDetails billingDetails, Cart cart)
+ TaxRate? taxRate,
+ Function(String total, BillingDetails? billingDetails, Cart cart)
completeCheckout) async {
String cartTotal = await CheckoutSession.getInstance
.total(withFormat: false, taxRate: taxRate);
- BillingDetails billingDetails = CheckoutSession.getInstance.billingDetails;
+ BillingDetails? billingDetails = CheckoutSession.getInstance.billingDetails;
Cart cart = Cart.getInstance;
return await completeCheckout(cartTotal, billingDetails, cart);
}
-double strCal({@required String sum}) {
- if (sum == null || sum == "") {
+double? strCal({required String sum}) {
+ if (sum == "") {
return 0;
}
Parser p = Parser();
@@ -200,7 +207,7 @@ double strCal({@required String sum}) {
return exp.evaluate(EvaluationType.REAL, cm);
}
-Future workoutShippingCostWC({@required String sum}) async {
+Future workoutShippingCostWC({required String? sum}) async {
if (sum == null || sum == "") {
return 0;
}
@@ -219,27 +226,27 @@ Future workoutShippingCostWC({@required String sum}) async {
if (replace.groupCount < 1) {
return "()";
}
- String newSum = replace.group(1);
+ String newSum = replace.group(1)!;
// PERCENT
String percentVal = newSum.replaceAllMapped(
defaultRegex(r'percent="([0-9\.]+)"'), (replacePercent) {
- if (replacePercent != null && replacePercent.groupCount >= 1) {
+ if (replacePercent.groupCount >= 1) {
String strPercentage = "( (" +
orderTotal.toString() +
" * " +
replacePercent.group(1).toString() +
") / 100 )";
- double calPercentage = strCal(sum: strPercentage);
+ double? calPercentage = strCal(sum: strPercentage);
// MIN
String strRegexMinFee = r'min_fee="([0-9\.]+)"';
if (defaultRegex(strRegexMinFee).hasMatch(newSum)) {
String strMinFee =
- defaultRegex(strRegexMinFee).firstMatch(newSum).group(1) ?? "0";
+ defaultRegex(strRegexMinFee).firstMatch(newSum)!.group(1) ?? "0";
double doubleMinFee = double.parse(strMinFee);
- if (calPercentage < doubleMinFee) {
+ if (calPercentage! < doubleMinFee) {
return "(" + doubleMinFee.toString() + ")";
}
newSum = newSum.replaceAll(defaultRegex(strRegexMinFee), "");
@@ -249,10 +256,10 @@ Future workoutShippingCostWC({@required String sum}) async {
String strRegexMaxFee = r'max_fee="([0-9\.]+)"';
if (defaultRegex(strRegexMaxFee).hasMatch(newSum)) {
String strMaxFee =
- defaultRegex(strRegexMaxFee).firstMatch(newSum).group(1) ?? "0";
+ defaultRegex(strRegexMaxFee).firstMatch(newSum)!.group(1) ?? "0";
double doubleMaxFee = double.parse(strMaxFee);
- if (calPercentage > doubleMaxFee) {
+ if (calPercentage! > doubleMaxFee) {
return "(" + doubleMaxFee.toString() + ")";
}
newSum = newSum.replaceAll(defaultRegex(strRegexMaxFee), "");
@@ -273,13 +280,13 @@ Future workoutShippingCostWC({@required String sum}) async {
return strCal(sum: sum);
}
-Future workoutShippingClassCostWC(
- {@required String sum, List cartLineItem}) async {
+Future workoutShippingClassCostWC(
+ {required String? sum, List? cartLineItem}) async {
if (sum == null || sum == "") {
return 0;
}
sum = sum.replaceAllMapped(defaultRegex(r'\[qty\]', strict: true), (replace) {
- return cartLineItem
+ return cartLineItem!
.map((f) => f.quantity)
.toList()
.reduce((i, d) => i + d)
@@ -292,27 +299,27 @@ Future workoutShippingClassCostWC(
if (replace.groupCount < 1) {
return "()";
}
- String newSum = replace.group(1);
+ String newSum = replace.group(1)!;
// PERCENT
String percentVal = newSum.replaceAllMapped(
defaultRegex(r'percent="([0-9\.]+)"'), (replacePercent) {
- if (replacePercent != null && replacePercent.groupCount >= 1) {
+ if (replacePercent.groupCount >= 1) {
String strPercentage = "( (" +
orderTotal.toString() +
" * " +
replacePercent.group(1).toString() +
") / 100 )";
- double calPercentage = strCal(sum: strPercentage);
+ double? calPercentage = strCal(sum: strPercentage);
// MIN
String strRegexMinFee = r'min_fee="([0-9\.]+)"';
if (defaultRegex(strRegexMinFee).hasMatch(newSum)) {
String strMinFee =
- defaultRegex(strRegexMinFee).firstMatch(newSum).group(1) ?? "0";
+ defaultRegex(strRegexMinFee).firstMatch(newSum)!.group(1) ?? "0";
double doubleMinFee = double.parse(strMinFee);
- if (calPercentage < doubleMinFee) {
+ if (calPercentage! < doubleMinFee) {
return "(" + doubleMinFee.toString() + ")";
}
newSum = newSum.replaceAll(defaultRegex(strRegexMinFee), "");
@@ -322,10 +329,10 @@ Future workoutShippingClassCostWC(
String strRegexMaxFee = r'max_fee="([0-9\.]+)"';
if (defaultRegex(strRegexMaxFee).hasMatch(newSum)) {
String strMaxFee =
- defaultRegex(strRegexMaxFee).firstMatch(newSum).group(1) ?? "0";
+ defaultRegex(strRegexMaxFee).firstMatch(newSum)!.group(1) ?? "0";
double doubleMaxFee = double.parse(strMaxFee);
- if (calPercentage > doubleMaxFee) {
+ if (calPercentage! > doubleMaxFee) {
return "(" + doubleMaxFee.toString() + ")";
}
newSum = newSum.replaceAll(defaultRegex(strRegexMaxFee), "");
@@ -348,7 +355,7 @@ Future workoutShippingClassCostWC(
RegExp defaultRegex(
String pattern, {
- bool strict,
+ bool? strict,
}) {
return RegExp(
pattern,
@@ -365,10 +372,10 @@ bool isEmail(String em) {
}
navigatorPush(BuildContext context,
- {@required String routeName,
- Object arguments,
+ {required String routeName,
+ Object? arguments,
bool forgetAll = false,
- int forgetLast}) {
+ int? forgetLast}) {
if (forgetAll) {
Navigator.of(context).pushNamedAndRemoveUntil(
routeName, (Route route) => false,
@@ -383,51 +390,11 @@ navigatorPush(BuildContext context,
Navigator.of(context).pushNamed(routeName, arguments: arguments);
}
-PlatformDialogAction dialogAction(BuildContext context,
- {@required title, ActionType actionType, Function() action}) {
- return PlatformDialogAction(
- actionType: actionType ?? ActionType.Default,
- child: Text(title ?? ""),
- onPressed: action ??
- () {
- Navigator.of(context).pop();
- },
- );
-}
-
-showPlatformAlertDialog(BuildContext context,
- {String title,
- String subtitle,
- List actions,
- bool showDoneAction = true}) {
- if (showDoneAction) {
- actions.add(dialogAction(context, title: trans("Done"), action: () {
- Navigator.of(context).pop();
- }));
- }
- showDialog(
- context: context,
- builder: (BuildContext context) {
- return PlatformAlertDialog(
- title: Text(title ?? ""),
- content: SingleChildScrollView(
- child: ListBody(
- children: [
- Text(subtitle ?? ""),
- ],
- ),
- ),
- actions: actions,
- );
- },
- );
-}
-
DateTime parseDateTime(String strDate) => DateTime.parse(strDate);
DateFormat formatDateTime(String format) => DateFormat(format);
-String dateFormatted({@required String date, @required String formatType}) =>
+String dateFormatted({required String date, required String formatType}) =>
formatDateTime(formatType).format(parseDateTime(date));
enum FormatType {
@@ -457,20 +424,20 @@ String formatForDateTime(FormatType formatType) {
}
}
-double parseWcPrice(String price) => (double.tryParse(price ?? "0") ?? 0);
+double parseWcPrice(String? price) => (double.tryParse(price ?? "0") ?? 0);
Widget refreshableScroll(context,
- {@required refreshController,
- @required VoidCallback onRefresh,
- @required VoidCallback onLoading,
- @required List products,
- @required onTap,
+ {required refreshController,
+ required VoidCallback onRefresh,
+ required VoidCallback onLoading,
+ required List products,
+ required onTap,
key}) {
return SmartRefresher(
enablePullDown: true,
enablePullUp: true,
footer: CustomFooter(
- builder: (BuildContext context, LoadStatus mode) {
+ builder: (BuildContext context, LoadStatus? mode) {
Widget body;
if (mode == LoadStatus.idle) {
body = Text(trans("pull up load"));
@@ -492,24 +459,24 @@ Widget refreshableScroll(context,
controller: refreshController,
onRefresh: onRefresh,
onLoading: onLoading,
- child: (products.length != null && products.isNotEmpty
- ? StaggeredGridView.countBuilder(
+ child: products.isEmpty
+ ? NoResultsForProductsWidget()
+ : StaggeredGrid.count(
crossAxisCount: 2,
- itemCount: products.length,
- itemBuilder: (BuildContext context, int index) {
- return Container(
- height: 200,
- child: ProductItemContainer(
- product: products[index],
- onTap: onTap,
- ),
- );
- },
- staggeredTileBuilder: (int index) => StaggeredTile.fit(1),
mainAxisSpacing: 4.0,
crossAxisSpacing: 4.0,
- )
- : NoResultsForProductsWidget()),
+ children: products.map((product) {
+ return StaggeredGridTile.fit(
+ crossAxisCellCount: 1,
+ child: Container(
+ height: 200,
+ child: ProductItemContainer(
+ product: product,
+ onTap: onTap,
+ ),
+ ),
+ );
+ }).toList()),
);
}
@@ -546,38 +513,46 @@ String truncateString(String data, int length) {
Future> getWishlistProducts() async {
List favouriteProducts = [];
- String currentProductsJSON = await NyStorage.read(SharedKey.wishlistProducts);
+ String? currentProductsJSON =
+ await (NyStorage.read(SharedKey.wishlistProducts));
if (currentProductsJSON != null) {
- favouriteProducts =
- (jsonDecode(currentProductsJSON) as List).toList();
+ favouriteProducts = (jsonDecode(currentProductsJSON)).toList();
}
return favouriteProducts;
}
-hasAddedWishlistProduct(int productId) async {
+hasAddedWishlistProduct(int? productId) async {
List favouriteProducts = await getWishlistProducts();
List productIds =
- favouriteProducts.map((e) => e['id']).cast().toList();
+ favouriteProducts.map((e) => e['id']).cast().toList();
if (productIds.isEmpty) {
- return false;
+ return false;
}
return productIds.contains(productId);
}
-saveWishlistProduct({@required Product product}) async {
+saveWishlistProduct({required Product? product}) async {
List products = await getWishlistProducts();
- if (products.any((wishListProduct) => wishListProduct['id'] == product.id) ==
+ if (products.any((wishListProduct) => wishListProduct['id'] == product!.id) ==
false) {
- products.add({"id": product.id});
+ products.add({"id": product!.id});
}
String json = jsonEncode(products.map((i) => {"id": i['id']}).toList());
await NyStorage.store(SharedKey.wishlistProducts, json);
}
-removeWishlistProduct({@required Product product}) async {
+removeWishlistProduct({required Product? product}) async {
List products = await getWishlistProducts();
- products.removeWhere((element) => element['id'] == product.id);
+ products.removeWhere((element) => element['id'] == product!.id);
String json = jsonEncode(products.map((i) => {"id": i['id']}).toList());
await NyStorage.store(SharedKey.wishlistProducts, json);
}
+
+/// API helper
+api(dynamic Function(T) request, {BuildContext? context}) async =>
+ await nyApi(
+ request: request, apiDecoders: apiDecoders, context: context);
+
+/// Event helper
+event({Map? data}) async => nyEvent(params: data, events: events);
diff --git a/LabelStoreMax/lib/bootstrap/shared_pref/sp_auth.dart b/LabelStoreMax/lib/bootstrap/shared_pref/sp_auth.dart
index ddac8b2..de0c392 100644
--- a/LabelStoreMax/lib/bootstrap/shared_pref/sp_auth.dart
+++ b/LabelStoreMax/lib/bootstrap/shared_pref/sp_auth.dart
@@ -12,13 +12,13 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter_app/app/models/cart.dart';
import 'package:flutter_app/bootstrap/helpers.dart';
import 'package:flutter_app/bootstrap/shared_pref/shared_key.dart';
-import 'package:nylo_support/helpers/helper.dart';
+import 'package:nylo_framework/nylo_framework.dart';
Future authCheck() async => ((await getUser()) != null);
-Future readAuthToken() async => (await getUser()).token;
+Future readAuthToken() async => (await getUser())!.token;
-Future readUserId() async => (await getUser()).userId;
+Future readUserId() async => (await getUser())!.userId;
authLogout(BuildContext context) async {
await NyStorage.delete(SharedKey.authUser);
diff --git a/LabelStoreMax/lib/config/app_currency.dart b/LabelStoreMax/lib/config/currency.dart
similarity index 89%
rename from LabelStoreMax/lib/config/app_currency.dart
rename to LabelStoreMax/lib/config/currency.dart
index ede8603..307f90b 100644
--- a/LabelStoreMax/lib/config/app_currency.dart
+++ b/LabelStoreMax/lib/config/currency.dart
@@ -18,7 +18,7 @@ import 'package:flutter_app/bootstrap/enums/symbol_position_enums.dart';
|--------------------------------------------------------------------------
*/
-const SymbolPositionType app_currency_symbol_position = SymbolPositionType.left;
+const SymbolPositionType appCurrencySymbolPosition = SymbolPositionType.left;
// currency_symbol_position example.
// left: $15
// right: 15€
diff --git a/LabelStoreMax/lib/config/decoders.dart b/LabelStoreMax/lib/config/decoders.dart
new file mode 100644
index 0000000..14c27d6
--- /dev/null
+++ b/LabelStoreMax/lib/config/decoders.dart
@@ -0,0 +1,30 @@
+import 'package:flutter_app/app/networking/api_service.dart';
+
+/*
+|--------------------------------------------------------------------------
+| Model Decoders
+| -------------------------------------------------------------------------
+| Model decoders are used in 'app/networking/' for morphing json payloads
+| into Models. Learn more https://nylo.dev/docs/3.x/decoders#model-decoders
+|--------------------------------------------------------------------------
+*/
+
+final Map modelDecoders = {
+ // ...
+};
+
+/*
+|--------------------------------------------------------------------------
+| API Decoders
+| -------------------------------------------------------------------------
+| API decoders are used when you need to access an API service using the
+| 'api' helper. E.g. api((request) => request.fetchData());
+| Learn more https://nylo.dev/docs/3.x/decoders#api-decoders
+|--------------------------------------------------------------------------
+*/
+
+final Map apiDecoders = {
+ ApiService: ApiService(),
+
+ // ...
+};
diff --git a/LabelStoreMax/lib/config/events.dart b/LabelStoreMax/lib/config/events.dart
new file mode 100644
index 0000000..6c92907
--- /dev/null
+++ b/LabelStoreMax/lib/config/events.dart
@@ -0,0 +1,18 @@
+import 'package:flutter_app/app/events/login_event.dart';
+import 'package:flutter_app/app/events/logout_event.dart';
+import 'package:nylo_framework/nylo_framework.dart';
+
+/*
+|--------------------------------------------------------------------------
+| Events
+| Add your "app/events" here.
+| Events can be fired using: event();
+|
+| Learn more: https://nylo.dev/docs/3.x/events
+|--------------------------------------------------------------------------
+*/
+
+final Map events = {
+ LoginEvent: LoginEvent(),
+ LogoutEvent: LogoutEvent(),
+};
diff --git a/LabelStoreMax/lib/config/app_font.dart b/LabelStoreMax/lib/config/font.dart
similarity index 100%
rename from LabelStoreMax/lib/config/app_font.dart
rename to LabelStoreMax/lib/config/font.dart
diff --git a/LabelStoreMax/lib/config/app_localization.dart b/LabelStoreMax/lib/config/localization.dart
similarity index 96%
rename from LabelStoreMax/lib/config/app_localization.dart
rename to LabelStoreMax/lib/config/localization.dart
index 156fe65..dc9cdd0 100644
--- a/LabelStoreMax/lib/config/app_localization.dart
+++ b/LabelStoreMax/lib/config/localization.dart
@@ -18,7 +18,7 @@ final LocaleType localeType = LocaleType.asDefined; // device, asDefined
| The language code should match the name of the file i.e /lang/es.json
|--------------------------------------------------------------------------
*/
-final String languageCode = getEnv('DEFAULT_LOCALE', defaultValue: "en");
+final String? languageCode = getEnv('DEFAULT_LOCALE', defaultValue: "en");
/*
|--------------------------------------------------------------------------
diff --git a/LabelStoreMax/lib/config/app_payment_gateways.dart b/LabelStoreMax/lib/config/payment_gateways.dart
similarity index 97%
rename from LabelStoreMax/lib/config/app_payment_gateways.dart
rename to LabelStoreMax/lib/config/payment_gateways.dart
index 86414fc..ce8b987 100644
--- a/LabelStoreMax/lib/config/app_payment_gateways.dart
+++ b/LabelStoreMax/lib/config/payment_gateways.dart
@@ -13,7 +13,7 @@ import 'package:flutter_app/bootstrap/helpers.dart';
|--------------------------------------------------------------------------
*/
-const app_payment_gateways = [];
+const appPaymentGateways = [];
// Available: "Stripe", "CashOnDelivery", "PayPal"
// e.g. app_payment_gateways = ["Stripe", "CashOnDelivery"]; will only use Stripe and Cash on Delivery.
diff --git a/LabelStoreMax/lib/config/providers.dart b/LabelStoreMax/lib/config/providers.dart
new file mode 100644
index 0000000..baf3b70
--- /dev/null
+++ b/LabelStoreMax/lib/config/providers.dart
@@ -0,0 +1,19 @@
+import 'package:flutter_app/app/providers/app_provider.dart';
+import 'package:flutter_app/app/providers/event_provider.dart';
+import 'package:flutter_app/app/providers/route_provider.dart';
+
+/*
+|--------------------------------------------------------------------------
+| Providers
+| Add your "app/providers" here.
+| Providers are booted when your application start.
+|
+| Learn more: https://nylo.dev/docs/3.x/providers
+|--------------------------------------------------------------------------
+*/
+
+final providers = {
+ AppProvider: AppProvider(),
+ RouteProvider: RouteProvider(),
+ EventProvider: EventProvider(),
+};
diff --git a/LabelStoreMax/lib/config/app_theme.dart b/LabelStoreMax/lib/config/theme.dart
similarity index 100%
rename from LabelStoreMax/lib/config/app_theme.dart
rename to LabelStoreMax/lib/config/theme.dart
diff --git a/LabelStoreMax/lib/generated_plugin_registrant.dart b/LabelStoreMax/lib/generated_plugin_registrant.dart
deleted file mode 100644
index b3657a6..0000000
--- a/LabelStoreMax/lib/generated_plugin_registrant.dart
+++ /dev/null
@@ -1,20 +0,0 @@
-//
-// Generated file. Do not edit.
-//
-
-// ignore_for_file: directives_ordering
-// ignore_for_file: lines_longer_than_80_chars
-
-import 'package:flutter_secure_storage_web/flutter_secure_storage_web.dart';
-import 'package:shared_preferences_web/shared_preferences_web.dart';
-import 'package:url_launcher_web/url_launcher_web.dart';
-
-import 'package:flutter_web_plugins/flutter_web_plugins.dart';
-
-// ignore: public_member_api_docs
-void registerPlugins(Registrar registrar) {
- FlutterSecureStorageWeb.registerWith(registrar);
- SharedPreferencesPlugin.registerWith(registrar);
- UrlLauncherPlugin.registerWith(registrar);
- registrar.registerMessageHandler();
-}
diff --git a/LabelStoreMax/lib/main.dart b/LabelStoreMax/lib/main.dart
index 462c7ed..5313d7b 100644
--- a/LabelStoreMax/lib/main.dart
+++ b/LabelStoreMax/lib/main.dart
@@ -2,21 +2,20 @@ import 'package:flutter/material.dart';
import 'package:flutter_app/bootstrap/app.dart';
import 'package:flutter_app/bootstrap/app_helper.dart';
import 'package:flutter_app/bootstrap/boot.dart';
-import 'package:flutter_app/routes/router.dart';
import 'package:nylo_framework/nylo_framework.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
- Nylo nylo = await Nylo.init(router: appRouter(), setup: boot);
+ Nylo nylo = await Nylo.init(setup: Boot.nylo, setupFinished: Boot.finished);
- String initialRoute = AppHelper.instance.appConfig.appStatus != null
+ String initialRoute = AppHelper.instance.appConfig!.appStatus != null
? '/home'
: '/no-connection';
runApp(
AppBuild(
- navigatorKey: nylo.router.navigatorKey,
- onGenerateRoute: nylo.router.generator(),
+ navigatorKey: NyNavigator.instance.router.navigatorKey,
+ onGenerateRoute: nylo.router!.generator(),
initialRoute: initialRoute,
debugShowCheckedModeBanner: false,
),
diff --git a/LabelStoreMax/lib/resources/pages/account_billing_details.dart b/LabelStoreMax/lib/resources/pages/account_billing_details.dart
index 8efb1b8..fc032c8 100644
--- a/LabelStoreMax/lib/resources/pages/account_billing_details.dart
+++ b/LabelStoreMax/lib/resources/pages/account_billing_details.dart
@@ -51,18 +51,18 @@ class _AccountBillingDetailsPageState extends State {
_fetchUserDetails() async {
WCCustomerInfoResponse wcCustomerInfoResponse =
await WPJsonAPI.instance.api((request) async {
- return request.wcCustomerInfo(await readAuthToken());
+ return request.wcCustomerInfo((await readAuthToken())!);
});
- Billing billing = wcCustomerInfoResponse.data.billing;
- _txtShippingFirstName.text = billing.firstName;
- _txtShippingLastName.text = billing.lastName;
+ Billing billing = wcCustomerInfoResponse.data!.billing!;
+ _txtShippingFirstName.text = billing.firstName!;
+ _txtShippingLastName.text = billing.lastName!;
- _txtShippingAddressLine.text = billing.address1;
- _txtShippingCity.text = billing.city;
- _txtShippingState.text = billing.state;
- _txtShippingPostalCode.text = billing.postcode;
- _txtShippingCountry.text = billing.country;
+ _txtShippingAddressLine.text = billing.address1!;
+ _txtShippingCity.text = billing.city!;
+ _txtShippingState.text = billing.state!;
+ _txtShippingPostalCode.text = billing.postcode!;
+ _txtShippingCountry.text = billing.country!;
setState(() {
_isLoading = false;
@@ -155,7 +155,7 @@ class _AccountBillingDetailsPageState extends State {
],
),
decoration: BoxDecoration(
- color: ThemeColor.get(context).surfaceBackground,
+ color: ThemeColor.get(context)!.surfaceBackground,
borderRadius: BorderRadius.circular(10),
boxShadow: (Theme.of(context).brightness ==
Brightness.light)
@@ -171,9 +171,9 @@ class _AccountBillingDetailsPageState extends State {
Column(
children: [
PrimaryButton(
- title: trans("UPDATE DETAILS"),
- isLoading: _isUpdating,
- action: _updateBillingDetails,
+ title: trans("UPDATE DETAILS"),
+ isLoading: _isUpdating,
+ action: _updateBillingDetails,
),
],
),
@@ -194,13 +194,13 @@ class _AccountBillingDetailsPageState extends State {
String postalCode = _txtShippingPostalCode.text;
String country = _txtShippingCountry.text;
- String userToken = await readAuthToken();
+ String? userToken = await readAuthToken();
setState(() {
_isUpdating = true;
});
- WCCustomerUpdatedResponse wcCustomerUpdatedResponse;
+ WCCustomerUpdatedResponse? wcCustomerUpdatedResponse;
try {
wcCustomerUpdatedResponse = await WPJsonAPI.instance.api((request) =>
request.wcUpdateCustomerInfo(userToken,
diff --git a/LabelStoreMax/lib/resources/pages/account_detail.dart b/LabelStoreMax/lib/resources/pages/account_detail.dart
index 8e12f3d..48f659c 100644
--- a/LabelStoreMax/lib/resources/pages/account_detail.dart
+++ b/LabelStoreMax/lib/resources/pages/account_detail.dart
@@ -31,10 +31,10 @@ class AccountDetailPage extends StatefulWidget {
class _AccountDetailPageState extends State
with SingleTickerProviderStateMixin {
- TabController _tabController;
+ TabController? _tabController;
bool _isLoading = true;
int _currentTabIndex = 0;
- WCCustomerInfoResponse _wcCustomerInfoResponse;
+ WCCustomerInfoResponse? _wcCustomerInfoResponse;
@override
void initState() {
@@ -44,12 +44,12 @@ class _AccountDetailPageState extends State
}
_fetchWpUserData() async {
- String userToken = await readAuthToken();
+ String? userToken = await readAuthToken();
- WCCustomerInfoResponse wcCustomerInfoResponse;
+ WCCustomerInfoResponse? wcCustomerInfoResponse;
try {
wcCustomerInfoResponse = await WPJsonAPI.instance
- .api((request) => request.wcCustomerInfo(userToken));
+ .api((request) => request.wcCustomerInfo(userToken!));
} on InvalidUserTokenException catch (_) {
showToastNotification(
context,
@@ -81,7 +81,7 @@ class _AccountDetailPageState extends State
@override
Widget build(BuildContext context) {
- Widget activeBody;
+ Widget? activeBody;
if (_currentTabIndex == 0) {
activeBody = AccountDetailOrdersWidget();
} else if (_currentTabIndex == 1) {
@@ -98,16 +98,15 @@ class _AccountDetailPageState extends State
if (activeBody == null) {
return SizedBox.shrink();
}
- String userAvatar;
- String userFirstName = "";
- String userLastName = "";
- if (_wcCustomerInfoResponse != null && _wcCustomerInfoResponse.data != null) {
- userAvatar = _wcCustomerInfoResponse.data.avatar;
+ String? userAvatar;
+ String? userFirstName = "";
+ String? userLastName = "";
+ if (_wcCustomerInfoResponse != null &&
+ _wcCustomerInfoResponse!.data != null) {
+ userAvatar = _wcCustomerInfoResponse!.data!.avatar;
- userFirstName = _wcCustomerInfoResponse
- .data.firstName;
- userLastName = _wcCustomerInfoResponse
- .data.lastName;
+ userFirstName = _wcCustomerInfoResponse!.data!.firstName;
+ userLastName = _wcCustomerInfoResponse!.data!.lastName;
}
return Scaffold(
appBar: AppBar(
@@ -142,9 +141,14 @@ class _AccountDetailPageState extends State
children: [
Container(
margin: EdgeInsets.only(top: 10),
- child: userAvatar != null ? CircleAvatar(
- backgroundImage: NetworkImage(userAvatar),
- ) : Icon(Icons.account_circle_rounded, size: 65,),
+ child: userAvatar != null
+ ? CircleAvatar(
+ backgroundImage: NetworkImage(userAvatar),
+ )
+ : Icon(
+ Icons.account_circle_rounded,
+ size: 65,
+ ),
height: 90,
width: 90,
),
@@ -161,11 +165,9 @@ class _AccountDetailPageState extends State
MainAxisAlignment.spaceAround,
children: [
Text(
- [
- userFirstName,
- userLastName
- ].where((t) =>
- (t != null || t != ""))
+ [userFirstName, userLastName]
+ .where(
+ (t) => (t != null || t != ""))
.toList()
.join(" "),
style: TextStyle(
@@ -210,7 +212,7 @@ class _AccountDetailPageState extends State
(Theme.of(context).brightness == Brightness.light)
? wsBoxShadow()
: null,
- color: ThemeColor.get(context).backgroundContainer,
+ color: ThemeColor.get(context)!.backgroundContainer,
),
),
Expanded(child: activeBody),
@@ -222,7 +224,7 @@ class _AccountDetailPageState extends State
@override
void dispose() {
- _tabController.dispose();
+ _tabController!.dispose();
super.dispose();
}
diff --git a/LabelStoreMax/lib/resources/pages/account_landing.dart b/LabelStoreMax/lib/resources/pages/account_landing.dart
index 057be79..a2cec19 100644
--- a/LabelStoreMax/lib/resources/pages/account_landing.dart
+++ b/LabelStoreMax/lib/resources/pages/account_landing.dart
@@ -65,7 +65,7 @@ class _AccountLandingPageState extends State {
child: Text(
trans("Login"),
textAlign: TextAlign.left,
- style: Theme.of(context).textTheme.headline4.copyWith(
+ style: Theme.of(context).textTheme.headline4!.copyWith(
fontSize: 24,
fontWeight: FontWeight.w700,
),
@@ -79,7 +79,7 @@ class _AccountLandingPageState extends State {
(Theme.of(context).brightness == Brightness.light)
? wsBoxShadow()
: null,
- color: ThemeColor.get(context).backgroundContainer,
+ color: ThemeColor.get(context)!.backgroundContainer,
),
padding: EdgeInsets.symmetric(vertical: 18, horizontal: 8),
margin: EdgeInsets.symmetric(horizontal: 16),
@@ -133,8 +133,8 @@ class _AccountLandingPageState extends State {
LinkButton(
title: trans("Forgot Password"),
action: () {
- String forgotPasswordUrl =
- AppHelper.instance.appConfig.wpLoginForgotPasswordUrl;
+ String? forgotPasswordUrl =
+ AppHelper.instance.appConfig!.wpLoginForgotPasswordUrl;
if (forgotPasswordUrl != null) {
openBrowserTab(url: forgotPasswordUrl);
} else {
@@ -155,7 +155,7 @@ class _AccountLandingPageState extends State {
: Padding(
padding: EdgeInsets.only(bottom: 20),
)
- ].where((element) => element != null).toList(),
+ ],
),
),
);
@@ -190,7 +190,7 @@ class _AccountLandingPageState extends State {
_hasTappedLogin = true;
});
- WPUserLoginResponse wpUserLoginResponse;
+ WPUserLoginResponse? wpUserLoginResponse;
try {
wpUserLoginResponse = await WPJsonAPI.instance.api(
(request) => request.wpLogin(email: email, password: password));
@@ -228,8 +228,8 @@ class _AccountLandingPageState extends State {
}
if (wpUserLoginResponse != null && wpUserLoginResponse.status == 200) {
- String token = wpUserLoginResponse.data.userToken;
- String userId = wpUserLoginResponse.data.userId.toString();
+ String? token = wpUserLoginResponse.data!.userToken;
+ String userId = wpUserLoginResponse.data!.userId.toString();
User user = User.fromUserAuthResponse(token: token, userId: userId);
user.save(SharedKey.authUser);
diff --git a/LabelStoreMax/lib/resources/pages/account_order_detail.dart b/LabelStoreMax/lib/resources/pages/account_order_detail.dart
index d1052ec..2388e51 100644
--- a/LabelStoreMax/lib/resources/pages/account_order_detail.dart
+++ b/LabelStoreMax/lib/resources/pages/account_order_detail.dart
@@ -14,28 +14,25 @@ import 'package:flutter_app/bootstrap/helpers.dart';
import 'package:flutter_app/resources/widgets/app_loader_widget.dart';
import 'package:flutter_app/resources/widgets/safearea_widget.dart';
import 'package:flutter_app/resources/widgets/woosignal_ui.dart';
-import 'package:nylo_support/helpers/helper.dart';
-import 'package:nylo_support/widgets/ny_state.dart';
-import 'package:nylo_support/widgets/ny_stateful_widget.dart';
+import 'package:nylo_framework/nylo_framework.dart';
import 'package:woosignal/models/response/order.dart';
class AccountOrderDetailPage extends NyStatefulWidget {
final AccountOrderDetailController controller =
AccountOrderDetailController();
- AccountOrderDetailPage({Key key}) : super(key: key);
+ AccountOrderDetailPage({Key? key}) : super(key: key);
@override
_AccountOrderDetailPageState createState() => _AccountOrderDetailPageState();
}
class _AccountOrderDetailPageState extends NyState {
- int _orderId;
- Order _order;
+ int? _orderId;
+ Order? _order;
bool _isLoading = true;
@override
- widgetDidLoad() async {
- super.widgetDidLoad();
+ init() async {
_orderId = widget.controller.data();
await _fetchOrder();
}
@@ -67,7 +64,7 @@ class _AccountOrderDetailPageState extends NyState {
child: Text(
"${trans("Date Ordered").capitalize()}: " +
dateFormatted(
- date: _order.dateCreated,
+ date: _order!.dateCreated!,
formatType: formatForDateTime(FormatType.date),
),
),
@@ -86,15 +83,15 @@ class _AccountOrderDetailPageState extends NyState {
child: Text(
[
[
- _order.shipping.firstName,
- _order.shipping.lastName
+ _order!.shipping!.firstName,
+ _order!.shipping!.lastName
].where((t) => t != null).toList().join(" "),
- _order.shipping.address1,
- _order.shipping.address2,
- _order.shipping.city,
- _order.shipping.state,
- _order.shipping.postcode,
- _order.shipping.country,
+ _order!.shipping!.address1,
+ _order!.shipping!.address2,
+ _order!.shipping!.city,
+ _order!.shipping!.state,
+ _order!.shipping!.postcode,
+ _order!.shipping!.country,
]
.where((t) => (t != "" && t != null))
.toList()
@@ -118,7 +115,7 @@ class _AccountOrderDetailPageState extends NyState {
Expanded(
child: ListView.builder(
itemBuilder: (cxt, i) {
- LineItems lineItem = _order.lineItems[i];
+ LineItems lineItem = _order!.lineItems![i];
return Card(
child: ListTile(
contentPadding: EdgeInsets.only(
@@ -137,7 +134,7 @@ class _AccountOrderDetailPageState extends NyState {
children: [
Flexible(
child: Text(
- lineItem.name,
+ lineItem.name!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
@@ -169,7 +166,7 @@ class _AccountOrderDetailPageState extends NyState {
),
style: Theme.of(context)
.textTheme
- .bodyText2
+ .bodyText2!
.copyWith(
fontWeight: FontWeight.w600,
),
@@ -190,7 +187,7 @@ class _AccountOrderDetailPageState extends NyState {
),
);
},
- itemCount: _order.lineItems.length,
+ itemCount: _order!.lineItems!.length,
),
),
],
@@ -205,9 +202,9 @@ class _AccountOrderDetailPageState extends NyState {
}
_fetchOrder() async {
- _order = await appWooSignal((api) {
- return api.retrieveOrder(_orderId);
- });
+ _order = await (appWooSignal((api) {
+ return api.retrieveOrder(_orderId!);
+ }));
if (_order != null) {
setState(() {
_isLoading = false;
diff --git a/LabelStoreMax/lib/resources/pages/account_profile_update.dart b/LabelStoreMax/lib/resources/pages/account_profile_update.dart
index 18714f7..ccbee42 100644
--- a/LabelStoreMax/lib/resources/pages/account_profile_update.dart
+++ b/LabelStoreMax/lib/resources/pages/account_profile_update.dart
@@ -47,11 +47,11 @@ class _AccountProfileUpdatePageState extends State {
_fetchUserDetails() async {
WPUserInfoResponse wpUserInfoResponse =
await WPJsonAPI.instance.api((request) async {
- return request.wpGetUserInfo(await readAuthToken());
+ return request.wpGetUserInfo((await readAuthToken()) ?? "0");
});
- _tfFirstName.text = wpUserInfoResponse.data.firstName;
- _tfLastName.text = wpUserInfoResponse.data.lastName;
+ _tfFirstName.text = wpUserInfoResponse.data!.firstName!;
+ _tfLastName.text = wpUserInfoResponse.data!.lastName!;
setState(() {
isLoading = false;
});
@@ -108,9 +108,9 @@ class _AccountProfileUpdatePageState extends State {
padding: EdgeInsets.only(top: 10),
),
PrimaryButton(
- title: trans("Update details"),
- isLoading: isLoading,
- action: _updateDetails,
+ title: trans("Update details"),
+ isLoading: isLoading,
+ action: _updateDetails,
)
],
),
@@ -133,8 +133,8 @@ class _AccountProfileUpdatePageState extends State {
isLoading = true;
});
- String userToken = await readAuthToken();
- WPUserInfoUpdatedResponse wpUserInfoUpdatedResponse;
+ String? userToken = await readAuthToken();
+ WPUserInfoUpdatedResponse? wpUserInfoUpdatedResponse;
try {
wpUserInfoUpdatedResponse = await WPJsonAPI.instance.api((request) =>
request.wpUpdateUserInfo(userToken,
diff --git a/LabelStoreMax/lib/resources/pages/account_register.dart b/LabelStoreMax/lib/resources/pages/account_register.dart
index 42d37c5..70017ed 100644
--- a/LabelStoreMax/lib/resources/pages/account_register.dart
+++ b/LabelStoreMax/lib/resources/pages/account_register.dart
@@ -47,7 +47,7 @@ class _AccountRegistrationPageState extends State {
_tfFirstNameController = TextEditingController(),
_tfLastNameController = TextEditingController();
- final WooSignalApp _wooSignalApp = AppHelper.instance.appConfig;
+ final WooSignalApp? _wooSignalApp = AppHelper.instance.appConfig;
@override
void initState() {
@@ -105,9 +105,9 @@ class _AccountRegistrationPageState extends State {
),
Padding(
child: PrimaryButton(
- title: trans("Sign up"),
- isLoading: _hasTappedRegister,
- action: _signUpTapped,
+ title: trans("Sign up"),
+ isLoading: _hasTappedRegister,
+ action: _signUpTapped,
),
padding: EdgeInsets.only(top: 10),
),
@@ -116,7 +116,7 @@ class _AccountRegistrationPageState extends State {
child: RichText(
text: TextSpan(
text: trans("By tapping \"Register\" you agree to ") +
- AppHelper.instance.appConfig.appName +
+ AppHelper.instance.appConfig!.appName! +
'\'s ',
children: [
TextSpan(
@@ -179,7 +179,7 @@ class _AccountRegistrationPageState extends State {
String username =
(email.replaceAll(RegExp(r'([@.])'), "")) + _randomStr(4);
- WPUserRegisterResponse wpUserRegisterResponse;
+ WPUserRegisterResponse? wpUserRegisterResponse;
try {
wpUserRegisterResponse = await WPJsonAPI.instance.api(
(request) => request.wpRegister(
@@ -232,8 +232,8 @@ class _AccountRegistrationPageState extends State {
if (wpUserRegisterResponse != null &&
wpUserRegisterResponse.status == 200) {
- String token = wpUserRegisterResponse.data.userToken;
- String userId = wpUserRegisterResponse.data.userId.toString();
+ String? token = wpUserRegisterResponse.data!.userToken;
+ String userId = wpUserRegisterResponse.data!.userId.toString();
User user = User.fromUserAuthResponse(token: token, userId: userId);
user.save(SharedKey.authUser);
@@ -251,17 +251,30 @@ class _AccountRegistrationPageState extends State {
}
}
- _viewTOSModal() {
- showPlatformAlertDialog(
- context,
- title: trans("Actions"),
- subtitle: trans("View Terms and Conditions or Privacy policy"),
- actions: [
- dialogAction(context,
- title: trans("Terms and Conditions"), action: _viewTermsConditions),
- dialogAction(context,
- title: trans("Privacy Policy"), action: _viewPrivacyPolicy),
- ],
+ _viewTOSModal() async {
+ await showDialog(
+ context: context,
+ builder: (context) => AlertDialog(
+ title: Text(trans("Actions")),
+ content: Text(trans("View Terms and Conditions or Privacy policy")),
+ actions: [
+ MaterialButton(
+ onPressed: _viewTermsConditions,
+ child: Text(trans("Terms and Conditions")),
+ ),
+ MaterialButton(
+ onPressed: _viewPrivacyPolicy,
+ child: Text(trans("Privacy Policy")),
+ ),
+ Divider(),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ child: Text('Close'),
+ ),
+ ],
+ ),
);
}
@@ -277,11 +290,11 @@ class _AccountRegistrationPageState extends State {
void _viewTermsConditions() {
Navigator.pop(context);
- openBrowserTab(url: _wooSignalApp.appTermsLink);
+ openBrowserTab(url: _wooSignalApp!.appTermsLink!);
}
void _viewPrivacyPolicy() {
Navigator.pop(context);
- openBrowserTab(url: _wooSignalApp.appPrivacyLink);
+ openBrowserTab(url: _wooSignalApp!.appPrivacyLink!);
}
}
diff --git a/LabelStoreMax/lib/resources/pages/account_shipping_details.dart b/LabelStoreMax/lib/resources/pages/account_shipping_details.dart
index b5111b3..2d9bd82 100644
--- a/LabelStoreMax/lib/resources/pages/account_shipping_details.dart
+++ b/LabelStoreMax/lib/resources/pages/account_shipping_details.dart
@@ -50,12 +50,12 @@ class _AccountShippingDetailsPageState
}
_fetchUserDetails() async {
- String userToken = await readAuthToken();
+ String? userToken = await readAuthToken();
- WCCustomerInfoResponse wcCustomerInfoResponse;
+ WCCustomerInfoResponse? wcCustomerInfoResponse;
try {
wcCustomerInfoResponse = await WPJsonAPI.instance
- .api((request) => request.wcCustomerInfo(userToken));
+ .api((request) => request.wcCustomerInfo(userToken!));
} on Exception catch (_) {
showToastNotification(
context,
@@ -73,15 +73,15 @@ class _AccountShippingDetailsPageState
if (wcCustomerInfoResponse != null &&
wcCustomerInfoResponse.status == 200) {
- Shipping shipping = wcCustomerInfoResponse.data.shipping;
- _txtShippingFirstName.text = shipping.firstName;
- _txtShippingLastName.text = shipping.lastName;
+ Shipping shipping = wcCustomerInfoResponse.data!.shipping!;
+ _txtShippingFirstName.text = shipping.firstName!;
+ _txtShippingLastName.text = shipping.lastName!;
- _txtShippingAddressLine.text = shipping.address1;
- _txtShippingCity.text = shipping.city;
- _txtShippingState.text = shipping.state;
- _txtShippingPostalCode.text = shipping.postcode;
- _txtShippingCountry.text = shipping.country;
+ _txtShippingAddressLine.text = shipping.address1!;
+ _txtShippingCity.text = shipping.city!;
+ _txtShippingState.text = shipping.state!;
+ _txtShippingPostalCode.text = shipping.postcode!;
+ _txtShippingCountry.text = shipping.country!;
}
}
@@ -172,7 +172,7 @@ class _AccountShippingDetailsPageState
],
),
decoration: BoxDecoration(
- color: ThemeColor.get(context).surfaceBackground,
+ color: ThemeColor.get(context)!.surfaceBackground,
borderRadius: BorderRadius.circular(10),
boxShadow: (Theme.of(context).brightness ==
Brightness.light)
@@ -188,9 +188,9 @@ class _AccountShippingDetailsPageState
Column(
children: [
PrimaryButton(
- title: trans("UPDATE DETAILS"),
- isLoading: _isUpdating,
- action: _updateShippingDetails,
+ title: trans("UPDATE DETAILS"),
+ isLoading: _isUpdating,
+ action: _updateShippingDetails,
),
],
),
@@ -211,7 +211,7 @@ class _AccountShippingDetailsPageState
String postalCode = _txtShippingPostalCode.text;
String country = _txtShippingCountry.text;
- String userToken = await readAuthToken();
+ String? userToken = await readAuthToken();
if (_isUpdating == true) {
return;
@@ -221,7 +221,7 @@ class _AccountShippingDetailsPageState
_isUpdating = true;
});
- WCCustomerUpdatedResponse wcCustomerUpdatedResponse;
+ WCCustomerUpdatedResponse? wcCustomerUpdatedResponse;
try {
wcCustomerUpdatedResponse = await WPJsonAPI.instance.api(
(request) => request.wcUpdateCustomerInfo(
diff --git a/LabelStoreMax/lib/resources/pages/browse_category.dart b/LabelStoreMax/lib/resources/pages/browse_category.dart
index a39f92f..c7975c9 100644
--- a/LabelStoreMax/lib/resources/pages/browse_category.dart
+++ b/LabelStoreMax/lib/resources/pages/browse_category.dart
@@ -17,23 +17,21 @@ import 'package:flutter_app/resources/widgets/app_loader_widget.dart';
import 'package:flutter_app/resources/widgets/buttons.dart';
import 'package:flutter_app/resources/widgets/safearea_widget.dart';
import 'package:flutter_app/resources/widgets/woosignal_ui.dart';
-import 'package:nylo_support/helpers/helper.dart';
-import 'package:nylo_support/widgets/ny_state.dart';
-import 'package:nylo_support/widgets/ny_stateful_widget.dart';
+import 'package:nylo_framework/nylo_framework.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:woosignal/models/response/product_category.dart';
import 'package:woosignal/models/response/products.dart' as ws_product;
class BrowseCategoryPage extends NyStatefulWidget {
final BrowseCategoryController controller = BrowseCategoryController();
- BrowseCategoryPage({Key key}) : super(key: key);
+ BrowseCategoryPage({Key? key}) : super(key: key);
@override
_BrowseCategoryPageState createState() => _BrowseCategoryPageState();
}
class _BrowseCategoryPageState extends NyState {
- ProductCategory productCategory;
+ ProductCategory? productCategory;
_BrowseCategoryPageState();
final RefreshController _refreshController =
@@ -46,8 +44,7 @@ class _BrowseCategoryPageState extends NyState {
bool _isLoading = true;
@override
- widgetDidLoad() async {
- super.widgetDidLoad();
+ init() async {
productCategory = widget.controller.data();
await fetchProducts();
}
@@ -66,7 +63,7 @@ class _BrowseCategoryPageState extends NyState {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(trans("Browse"), style: Theme.of(context).textTheme.subtitle1),
- Text(parseHtmlString(productCategory.name))
+ Text(parseHtmlString(productCategory!.name))
],
),
centerTitle: true,
@@ -115,7 +112,7 @@ class _BrowseCategoryPageState extends NyState {
}
}
- _sortProducts({@required SortByType by}) {
+ _sortProducts({required SortByType by}) {
List products =
_productCategorySearchLoaderController.getResults();
switch (by) {
@@ -133,12 +130,12 @@ class _BrowseCategoryPageState extends NyState {
break;
case SortByType.nameAZ:
products.sort(
- (product1, product2) => product1.name.compareTo(product2.name),
+ (product1, product2) => product1.name!.compareTo(product2.name!),
);
break;
case SortByType.nameZA:
products.sort(
- (product1, product2) => product2.name.compareTo(product1.name),
+ (product1, product2) => product2.name!.compareTo(product1.name!),
);
break;
}
diff --git a/LabelStoreMax/lib/resources/pages/browse_search.dart b/LabelStoreMax/lib/resources/pages/browse_search.dart
index 3056bdb..f098e7b 100644
--- a/LabelStoreMax/lib/resources/pages/browse_search.dart
+++ b/LabelStoreMax/lib/resources/pages/browse_search.dart
@@ -14,15 +14,13 @@ import 'package:flutter_app/app/controllers/product_search_loader_controller.dar
import 'package:flutter_app/bootstrap/helpers.dart';
import 'package:flutter_app/resources/widgets/app_loader_widget.dart';
import 'package:flutter_app/resources/widgets/safearea_widget.dart';
-import 'package:nylo_support/helpers/helper.dart';
-import 'package:nylo_support/widgets/ny_state.dart';
-import 'package:nylo_support/widgets/ny_stateful_widget.dart';
+import 'package:nylo_framework/nylo_framework.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:woosignal/models/response/products.dart' as ws_product;
class BrowseSearchPage extends NyStatefulWidget {
final BrowseSearchController controller = BrowseSearchController();
- BrowseSearchPage({Key key}) : super(key: key);
+ BrowseSearchPage({Key? key}) : super(key: key);
@override
_BrowseSearchState createState() => _BrowseSearchState();
@@ -34,12 +32,11 @@ class _BrowseSearchState extends NyState {
final ProductSearchLoaderController _productSearchLoaderController =
ProductSearchLoaderController();
- String _search;
+ String? _search;
bool _shouldStopRequests = false, _isLoading = true;
@override
- widgetDidLoad() async {
- super.widgetDidLoad();
+ init() async {
_search = widget.controller.data();
await fetchProducts();
}
@@ -59,7 +56,7 @@ class _BrowseSearchState extends NyState {
children: [
Text(trans("Search results for"),
style: Theme.of(context).textTheme.subtitle1),
- Text("\"" + _search + "\"")
+ Text("\"" + _search! + "\"")
],
),
centerTitle: true,
diff --git a/LabelStoreMax/lib/resources/pages/cart.dart b/LabelStoreMax/lib/resources/pages/cart.dart
index aed5b81..bf6c298 100644
--- a/LabelStoreMax/lib/resources/pages/cart.dart
+++ b/LabelStoreMax/lib/resources/pages/cart.dart
@@ -56,7 +56,7 @@ class _CartPageState extends State {
List