Check for numeric value

This commit is contained in:
WooSignal 2019-11-12 15:55:10 +00:00
parent ecd217652f
commit e72d74a3cf

View File

@ -96,6 +96,7 @@ class _CheckoutShippingTypePageState extends State<CheckoutShippingTypePage> {
if (_shipping.methods.freeShipping != null) {
_shipping.methods.freeShipping.forEach((freeShipping) {
if (_isNumeric(freeShipping.cost)) {
Map<String, dynamic> tmpShippingOption = {};
tmpShippingOption = {
"id": freeShipping.id,
@ -105,6 +106,7 @@ class _CheckoutShippingTypePageState extends State<CheckoutShippingTypePage> {
"object": freeShipping
};
_wsShippingOptions.add(tmpShippingOption);
}
});
}
}
@ -118,6 +120,13 @@ class _CheckoutShippingTypePageState extends State<CheckoutShippingTypePage> {
});
}
bool _isNumeric(String str) {
if(str == null) {
return false;
}
return double.tryParse(str) != null;
}
Future<String> _getShippingPrice(int index) async {
double total = 0;
List<CartLineItem> cartLineItem = await Cart.getInstance.getCart();