title: snapshot.hasData returning false even though response.body has data [Flutter]
body: <p>I am trying to get current weather info from OpenWeather and display the result in Text Widget after checking that there is data returned. However, that condtion (snapshot.hasData) is always returned as false and else condition (CircularProgressIndicator) is invoked.
  <strong>Here is the FutureBuilder.</strong></p>
  <pre><code>class WeatherPage extends StatefulWidget {
    @override
    State&lt;WeatherPage&gt; createState() =&gt; _WeatherPageState();
  }
  
  class _WeatherPageState extends State&lt;WeatherPage&gt; {
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: Center(
          child: FutureBuilder(
            future: getCurrentWeather(),
            builder: (context, snapshot) {
              if (snapshot.hasData) {
                WeatherModelCurrent weather =
                    snapshot.data as WeatherModelCurrent;
  
                return weatherBox(weather);
              } else {
                return const CircularProgressIndicator();
              }
            },
          ),
        ),
      );
    }
  </code></pre>
  <p><strong>here is the getCurrentWeather() function</strong></p>
  <pre><code>Future getCurrentWeather() async {
      WeatherModelCurrent? weather;
  
      var url = Uri.parse(
          &quot;https://api.openweathermap.org/data/2.5/weather?q=Kathmandu&amp;appid=82c7b99e2a8215351147f607592a3e63&amp;units=metric&quot;);
      var response = await http.get(url);
  //response.body has the data returned by API call
      print(response.body);
  
      if (response.statusCode == 200) {
        weather = WeatherModelCurrent.frommJson(jsonDecode(response.body));
      
      } else {
        print('error');
      }
  
      return weather;
    }
  </code></pre>
  <p><strong>and here is the model class</strong></p>
  <pre><code>class WeatherModelCurrent {
    double temp;
    double feelslike;
    double tempmin;
    double tempmax;
    String description;
  
    WeatherModelCurrent(
        {required this.temp,
        required this.feelslike,
        required this.tempmin,
        required this.tempmax,
        required this.description});
  
    factory WeatherModelCurrent.frommJson(Map&lt;String, dynamic&gt; jsonn) {
      return WeatherModelCurrent(
        temp: jsonn['main']['temp'].toDouble(),
        feelslike: jsonn['main']['feels_like'].toDouble(),
        tempmin: jsonn['main']['temp_min'].toDouble(),
        tempmax: jsonn['main']['temp_max'].toDouble(),
        description: jsonn['weather']['description'],
      );
    }
  }
  </code></pre>