cph-cachet / flutter-plugins

A collection of Flutter plugins developed by CACHET
545 stars 656 forks source link

[weather] parsing api response is broken #343

Closed guenth39 closed 3 years ago

guenth39 commented 3 years ago

Device / Emulator and OS

Please complete the following information for each phone and/or emulator you're experiencing this bug on: Not Platform related

NB: Bugs pertaining to old devices/OS versions will likely not be fixed.

Describe the bug

Values that come from the API as int and should be parsed in the Weather class as double are not matched. An example for this is _windDegree or humidity, it is always null.

To Reproduce

Run example App and load weather.

Expected behavior

The _unpackDouble function should also accept int and parse it to double.

Actual behavior

API Response:

{
   "coord":{
      "lon":9,
      "lat":48
   },
   "weather":[
      {
         "id":500,
         "main":"Rain",
         "description":"light rain",
         "icon":10d
      }
   ],
   "base":"stations",
   "main":{
      "temp":279.87,
      "feels_like":276.48,
      "temp_min":278.15,
      "temp_max":281.48,
      "pressure":1013,
      "humidity":81
   },
   "visibility":10000,
   "wind":{
      "speed":5.36,
      "deg":337
   },
   "rain":{
      "1h":0.65
   },
   "clouds":{
      "all":100
   },
   "dt":1619879340,
   "sys":{
      "type":3,
      "id":2000043,
      "country":"DE",
      "sunrise":1619841940,
      "sunset":1619894179
   },
   "timezone":7200,
   "id":2942451,
   "name":"Buchheim",
   "cod":200
}

Weather Object:

          Place Name: Buchheim [DE] (null, null)
          Date: 2021-05-01 16:29:00.000
          Weather: Rain, light rain
          Temp: 6.7 Celsius, Temp (min): 5.0 Celsius, Temp (max): 8.3 Celsius,  Temp (feels like): 3.3 Celsius
          Sunrise: 2021-05-01 06:05:40.000, Sunset: 2021-05-01 20:36:19.000
          Wind: speed 5.36, degree: null, gust null
          Weather Condition code: 500

Screenshots

If applicable, add screenshots to help explain your problem.

Flutter doctor

Please run flutter doctor and add the output here.

Additional information

Add any other info about the problem here.

prantto commented 3 years ago

I got the same problem. Wanted to get the pressure, humidity and cloudiness, but it always returns null. The DateTime values (sunrise and sunset) and the areaName (string) works fine. Temperature is working fine. It really seams like original int values doesn't work.

Edit: Pull Request works fine, pls merge it soon.