Giter Club home page Giter Club logo

Comments (18)

Rohan2309 avatar Rohan2309 commented on August 28, 2024 6

use var

from clima-flutter-completed.

azeemgujjar avatar azeemgujjar commented on August 28, 2024 5

seems Dart is totally garbage

from clima-flutter-completed.

alihusainsorathiya avatar alihusainsorathiya commented on August 28, 2024 3

@simplygkgk @Samikhanonco instead of double temp replace it with var temp

from clima-flutter-completed.

Rohan2309 avatar Rohan2309 commented on August 28, 2024 2

I got the similar problem. I used var then it got solved.

from clima-flutter-completed.

kiranojhanp avatar kiranojhanp commented on August 28, 2024 1

#26
Avoid use of var. Its better to use dart as strongly tyoed.

from clima-flutter-completed.

Samikhanonco avatar Samikhanonco commented on August 28, 2024

thanx bro

from clima-flutter-completed.

simplygkgk avatar simplygkgk commented on August 28, 2024

Where to replace var??
@Samikhanonco

from clima-flutter-completed.

gaetanosestito avatar gaetanosestito commented on August 28, 2024

Hi, I solved using var temp

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

thanks @Rohan2309

from clima-flutter-completed.

sandeep1dimri avatar sandeep1dimri commented on August 28, 2024

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.

rohitsinghkcodes avatar rohitsinghkcodes commented on August 28, 2024

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.

reyad2020 avatar reyad2020 commented on August 28, 2024

Hi, I solved using var temp

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

thanks @Rohan2309

thanx it worked

from clima-flutter-completed.

reyad2020 avatar reyad2020 commented on August 28, 2024

thanx it worked

from clima-flutter-completed.

looloo404 avatar looloo404 commented on August 28, 2024

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.

Nisa-fatima369 avatar Nisa-fatima369 commented on August 28, 2024

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.

zoenie123 avatar zoenie123 commented on August 28, 2024

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.

rifat-22 avatar rifat-22 commented on August 28, 2024

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.

zoenie123 avatar zoenie123 commented on August 28, 2024

@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.

Woyinkuro avatar Woyinkuro commented on August 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.