I have problems while I try to get double values from JSON in Flutter.
class MapPoint {
String title;
double lat;
double lng;
MapPoint({this.title, this.lat, this.lng});
factory MapPoint.fromJson(Map<String, dynamic> json) {
return MapPoint(
title: json["title"] as String,
lat: json["lat"] as double,
lng: json["lng"] as double
);
}
}
For some reason I got error
Dart Error: Unhandled exception: type 'double' is not a subtype of type 'String'
I tried some to user double.parse(json["lng"]) instead but got same error.
Same time this way of getting data from JSON works fine with other types.
This is JSON example
{
point: {
title: "Point title",
lat: 42.123456,
lng: 32.26567
}
}
,missing after"Point title". Double values are never represented asStringin JSON.