Reputation: 51
I have this error : Unhandled Exception: type 'int' is not a subtype of type 'String' on this line of code :
double d=double.parse(map2["gain_gem"]);
map2["gain_gem"] is returned by php script api and return value 1
And after i try to do this :
globals.points = globals.points+d;
i have tried too :
globals.points = globals.points+double.parse(map2["gain_gem"]);
same problem
globals.points is defined as double in my script
double points=0;
Upvotes: 2
Views: 1251
Reputation: 644
You need to setup the int as a String first. The map2 value "gain_gem" is an int, that's where your error is coming from but to parse that value as a double it needs to be a String so if you toString the input it will be able to change it to a double. You should definitely make sure it will always be an int of course.
double d=double.parse(map2["gain_gem"].toString());
Documentation on toString()
Upvotes: 1