Fix exchange limits issue (#545)

* Allow nullable values from limits API

* Handle null values in SideShift limits API response
This commit is contained in:
Omar Hatem 2022-10-20 00:20:11 +02:00 committed by GitHub
parent c7ea9d52ee
commit a2dfbc6076
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -85,8 +85,8 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
final responseJSON = json.decode(response.body) as Map<String, dynamic>; final responseJSON = json.decode(response.body) as Map<String, dynamic>;
return Limits( return Limits(
min: responseJSON['minAmount'] as double, min: responseJSON['minAmount'] as double?,
max: responseJSON['maxAmount'] as double); max: responseJSON['maxAmount'] as double?);
} }
@override @override

View file

@ -192,8 +192,8 @@ class SideShiftExchangeProvider extends ExchangeProvider {
} }
final responseJSON = json.decode(response.body) as Map<String, dynamic>; final responseJSON = json.decode(response.body) as Map<String, dynamic>;
final min = double.parse(responseJSON['min'] as String); final min = double.tryParse(responseJSON['min'] as String? ?? '');
final max = double.parse(responseJSON['max'] as String); final max = double.tryParse(responseJSON['max'] as String? ?? '');
return Limits(min: min, max: max); return Limits(min: min, max: max);
} }