londonappbrewery / Clima-Flutter-Completed

The completed code for the Clima Project - The Complete Flutter Development Bootcamp

Home Page:https://www.appbrewery.co/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Int is not subtype of double

Aditi10101999 opened this issue · comments

when i try to run the app it shows this error "Int is not subtype of double" idk what to do

Change the variable type to 'dynamic', It worked for me

This error is because of open weather API

Replace

double temp = weatherData['main']['temp'];
temperature = temp.toInt();

with

if (weatherData['main']['temp'].runtimeType == double) {
 double temp = weatherData['main']['temp'];
 temperature = temp.toInt();
} else {
 temperature = weatherData['main']['temp'];
} 

and it should work.