From e72d74a3cf75c5a0b14e856b56382a736d636eaa Mon Sep 17 00:00:00 2001 From: WooSignal Date: Tue, 12 Nov 2019 15:55:10 +0000 Subject: [PATCH] Check for numeric value --- .../lib/pages/checkout_shipping_type.dart | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/LabelStoreMax/lib/pages/checkout_shipping_type.dart b/LabelStoreMax/lib/pages/checkout_shipping_type.dart index 06be3c6..ff205b6 100644 --- a/LabelStoreMax/lib/pages/checkout_shipping_type.dart +++ b/LabelStoreMax/lib/pages/checkout_shipping_type.dart @@ -96,15 +96,17 @@ class _CheckoutShippingTypePageState extends State { if (_shipping.methods.freeShipping != null) { _shipping.methods.freeShipping.forEach((freeShipping) { - Map tmpShippingOption = {}; - tmpShippingOption = { - "id": freeShipping.id, - "method_id": "free_shipping", - "title": freeShipping.title, - "cost": freeShipping.cost, - "object": freeShipping - }; - _wsShippingOptions.add(tmpShippingOption); + if (_isNumeric(freeShipping.cost)) { + Map tmpShippingOption = {}; + tmpShippingOption = { + "id": freeShipping.id, + "method_id": "free_shipping", + "title": freeShipping.title, + "cost": freeShipping.cost, + "object": freeShipping + }; + _wsShippingOptions.add(tmpShippingOption); + } }); } } @@ -118,6 +120,13 @@ class _CheckoutShippingTypePageState extends State { }); } + bool _isNumeric(String str) { + if(str == null) { + return false; + } + return double.tryParse(str) != null; + } + Future _getShippingPrice(int index) async { double total = 0; List cartLineItem = await Cart.getInstance.getCart();