Ive tried to use double.parse, double.tryparse as well as trying to convert it to int but it keeps giving the error ‘type ‘int’ is not a subtype of type ‘String”, ive searched a few sites but all the solutions show to use parse.
final locData = Map<String, dynamic>.from(local);
var dubLat = locData['lat'];
var lat = double.tryParse(dubLat);
ive tried changing var to double nit still give the same error.
2
Answers
You are facing this error because you are trying to pass int but double.tryParse need string value that’s why getting this error ‘type ‘int’ is not a subtype of type ‘String’
I solved by this ‘double.tryParse(dubLat.toString());’
The .tryParse takes a string or even the parse method for this instance takes a string. But your data is actually integers therefore the error type int is not a subtype of type string. You should consider either storing them as ints or using the .toString method before parsing them.