londonappbrewery / Clima-Flutter

Starter code for the Clima Project from the Complete Flutter Development Bootcamp
https://www.appbrewery.co
155 stars 740 forks source link

I have issue in getlocationData() method using Navigator.push of LocationScreen(); #36

Open Midhunap opened 1 year ago

Midhunap commented 1 year ago

while using Navigator.push of loadingScreen

Error :'Do not use BuildContext of async gaps'

void getLocationData() async { Location location = Location(); await location.getCurrentLocation(); longitude = location.longitude; latitude = location.latitude;

NetworkHelper networkHelper = NetworkHelper(
    'https://api.openweathermap.org/data/2.5/weather?lat=$latitude&lon=$longitude&appid=$apiKey');

var weatherData = await networkHelper.getData();

Navigator.push(context, MaterialPageRoute(builder: (context){
  return LocationScreen();

}));

}