I’m receiving data from an API that provides a weather info, for simplicity i will provide just an attribute of the received data:
final double feels_like;
and in json deserialization:
feels_Like = json['main']['feels_like']
But i got that Exception : type 'int' is not a subtype of type 'double'
, actually i solved it (using toDouble()
) no problem here, the problem is in the following concept.
Suppose the returned value is an int, can’t a double hold it?
for example:
double feels_like = 30.1; // ok
double feels_like = 30; // also ok
Both data types are sub types of base num
class and a double object can holds an int object but not vice versa.
So, Why is that happening while working with the API even if it returns an int
.