From a2dfbc607653cd31e49e084d387d856daa51336e Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Thu, 20 Oct 2022 00:20:11 +0200 Subject: [PATCH] Fix exchange limits issue (#545) * Allow nullable values from limits API * Handle null values in SideShift limits API response --- lib/exchange/changenow/changenow_exchange_provider.dart | 4 ++-- lib/exchange/sideshift/sideshift_exchange_provider.dart | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/exchange/changenow/changenow_exchange_provider.dart b/lib/exchange/changenow/changenow_exchange_provider.dart index 3c9c9f3bc..b663b697c 100644 --- a/lib/exchange/changenow/changenow_exchange_provider.dart +++ b/lib/exchange/changenow/changenow_exchange_provider.dart @@ -85,8 +85,8 @@ class ChangeNowExchangeProvider extends ExchangeProvider { final responseJSON = json.decode(response.body) as Map; return Limits( - min: responseJSON['minAmount'] as double, - max: responseJSON['maxAmount'] as double); + min: responseJSON['minAmount'] as double?, + max: responseJSON['maxAmount'] as double?); } @override diff --git a/lib/exchange/sideshift/sideshift_exchange_provider.dart b/lib/exchange/sideshift/sideshift_exchange_provider.dart index 87205cd2b..ff489aa83 100644 --- a/lib/exchange/sideshift/sideshift_exchange_provider.dart +++ b/lib/exchange/sideshift/sideshift_exchange_provider.dart @@ -192,8 +192,8 @@ class SideShiftExchangeProvider extends ExchangeProvider { } final responseJSON = json.decode(response.body) as Map; - final min = double.parse(responseJSON['min'] as String); - final max = double.parse(responseJSON['max'] as String); + final min = double.tryParse(responseJSON['min'] as String? ?? ''); + final max = double.tryParse(responseJSON['max'] as String? ?? ''); return Limits(min: min, max: max); }