Comments (18)
use var
from clima-flutter-completed.
seems Dart is totally garbage
from clima-flutter-completed.
@simplygkgk @Samikhanonco instead of double temp replace it with var temp
from clima-flutter-completed.
I got the similar problem. I used var then it got solved.
from clima-flutter-completed.
#26
Avoid use of var. Its better to use dart as strongly tyoed.
from clima-flutter-completed.
thanx bro
from clima-flutter-completed.
Where to replace var??
@Samikhanonco
from clima-flutter-completed.
Hi, I solved using var temp
var temp = weatherData['main']['temp'];
temperature = temp.toInt();
thanks @Rohan2309
from clima-flutter-completed.
i observed that for some cities or (latitude and longitude), the JSON return temperature as int, example like below (23 not 23.00)
{coord: {lon: -xxx, lat: xxx}, weather: [{id: 800, main: Clear, description: clear sky, icon: 01n}], base: stations, main: {temp: 23
so 23 is int not double. so i made generic change to convert it to double and then it works well.
setState(() {
double temp = (weatherData['main']['temp']).toDouble();
from clima-flutter-completed.
just initialize temperature with int then store the fetched location's temperature temporarily in var at last typecast it in int
int temperature;
.
.
var temp = weatherData['main']['temp'];
temperature = temp.toInt();
from clima-flutter-completed.
Hi, I solved using var temp
var temp = weatherData['main']['temp']; temperature = temp.toInt();
thanks @Rohan2309
thanx it worked
from clima-flutter-completed.
thanx it worked
from clima-flutter-completed.
Hi, I solved using var temp
var temp = weatherData['main']['temp']; temperature = temp.toInt();
thanks @Rohan2309
I got the similar problem. I used var then it got solved.
thanks to you i can solve proplem
from clima-flutter-completed.
i observed that for some cities or (latitude and longitude), the JSON return temperature as int, example like below (23 not 23.00) {coord: {lon: -xxx, lat: xxx}, weather: [{id: 800, main: Clear, description: clear sky, icon: 01n}], base: stations, main: {temp: 23
so 23 is int not double. so i made generic change to convert it to double and then it works well. setState(() { double temp = (weatherData['main']['temp']).toDouble();
unfortunately , I have the sem issue but the solution isn't workin well with my case
from clima-flutter-completed.
use var
No ... use num instead of double in this case. Always avoid var when possible.
num? temperature;
temperature = weatherData['main']['temp'];
or
num temperature = 0.0;
temperature = weatherData['main']['temp'];
I consider it also bad API design when numeric values flip between double and int in json, but unfortunately we have to deal with it in this case.
from clima-flutter-completed.
use var
No ... use num instead of double in this case. Always avoid var when possible.
num? temperature; temperature = weatherData['main']['temp'];
or
num temperature = 0.0; temperature = weatherData['main']['temp'];
I consider it also bad API design when numeric values flip between double and int in json, but unfortunately we have to deal with it in this case.
@zoenie123 , There is a workaround if the json data flips between double and int. This helped me. Take a look.
https://stackoverflow.com/a/62396418/11445727
from clima-flutter-completed.
@rifat-22 I stand with my solution, it's the most simple and fast one. All other versions I have seen do conversion on conversion. No need.
from clima-flutter-completed.
Hi, I solved using var temp
var temp = weatherData['main']['temp']; temperature = temp.toInt();
thanks @Rohan2309
I tried this but it didn't work
from clima-flutter-completed.
Related Issues (20)
- Pressing back button takes to endless loading screen HOT 1
- Recompile with -Xlint HOT 2
- followed the ful tutorial but i am getting this error HOT 1
- App not running on real device even itβs successfully installed HOT 2
- Cant fetch the location even comapre to final/completed project
- forming Custom variable for the "in" between weatherMessage and cityName
- Int is not subtype of double HOT 2
- If you stuck at loading screen on Android Emulator
- Build failed with an exception
- s\
- Error
- Int is not subtype of double || This error is because of open weather API HOT 2
- Use SetState () HOT 1
- Stuck on Loading screen on real device. HOT 1
- _LoadingScreenState.initState() returned a Future. State.initState()
- After build the apk and try to open it on phone, it stuck on the loading Screen HOT 1
- Assertion failed HOT 1
- Build failed due to use of deprecated Android v1 embedding. HOT 2
- deprecated geolocator dependancy
- depreciated code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clima-flutter-completed.