Handle price_change_percentage_24h being null and not able to parse as double

This commit is contained in:
likho 2023-06-06 16:34:43 +02:00
parent a79d8a802f
commit 14f9dc2c05

View file

@ -105,8 +105,8 @@ class PriceAPI {
final coin = coinFromPrettyName(coinName);
final price = Decimal.parse(map["current_price"].toString());
final change24h =
double.parse(map["price_change_percentage_24h"].toString());
final change24h = map["price_change_percentage_24h"] != null ?
double.parse(map["price_change_percentage_24h"].toString()) : 0.0;
result[coin] = Tuple2(price, change24h);
}