'Class 'Future<dynamic>' has no instance method '[]'
enter image description hereFuture dynamic not working please help trying to make a weather app
class WeatherModel {
Future<dynamic> getLocationWeather() async{
Location location = Location();
await location.getCurrentLocation();
Networkhelper networkhelper = Networkhelper(
'$openWeatherMapURL
lat=${location.latitude}&lon=${location.longitude}&appid=$apiKey&units=metric');
var weatherData = await networkhelper.getData();
return weatherData;
}}
Solution 1:[1]
your code should look like this:
Confirm your URL matches mine. Seems like you're missing ?.
Future<dynamic> getLocationWeather() async {
Location location = Location();
await location.getCurrentLocation();
NetworkHelper networkHelper = NetworkHelper(
url: // if you used a positional argument.
'$openWeatherMapURL?lat=${location.latitude}&lon=${location.longitude}&appid=$apiKey&units=metric');
var weatherData = await networkHelper.getData();
return weatherData;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | nonsocchi |
