Skip to content

Commit e72d74a

Browse files
author
WooSignal
committed
Check for numeric value
1 parent ecd2176 commit e72d74a

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

LabelStoreMax/lib/pages/checkout_shipping_type.dart

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,17 @@ class _CheckoutShippingTypePageState extends State<CheckoutShippingTypePage> {
9696

9797
if (_shipping.methods.freeShipping != null) {
9898
_shipping.methods.freeShipping.forEach((freeShipping) {
99-
Map<String, dynamic> tmpShippingOption = {};
100-
tmpShippingOption = {
101-
"id": freeShipping.id,
102-
"method_id": "free_shipping",
103-
"title": freeShipping.title,
104-
"cost": freeShipping.cost,
105-
"object": freeShipping
106-
};
107-
_wsShippingOptions.add(tmpShippingOption);
99+
if (_isNumeric(freeShipping.cost)) {
100+
Map<String, dynamic> tmpShippingOption = {};
101+
tmpShippingOption = {
102+
"id": freeShipping.id,
103+
"method_id": "free_shipping",
104+
"title": freeShipping.title,
105+
"cost": freeShipping.cost,
106+
"object": freeShipping
107+
};
108+
_wsShippingOptions.add(tmpShippingOption);
109+
}
108110
});
109111
}
110112
}
@@ -118,6 +120,13 @@ class _CheckoutShippingTypePageState extends State<CheckoutShippingTypePage> {
118120
});
119121
}
120122

123+
bool _isNumeric(String str) {
124+
if(str == null) {
125+
return false;
126+
}
127+
return double.tryParse(str) != null;
128+
}
129+
121130
Future<String> _getShippingPrice(int index) async {
122131
double total = 0;
123132
List<CartLineItem> cartLineItem = await Cart.getInstance.getCart();

0 commit comments

Comments
 (0)