londonappbrewery / Clima-Flutter-Completed

The completed code for the Clima Project - The Complete Flutter Development Bootcamp

Home Page:https://www.appbrewery.co/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App crashes when location permission is denied on android emulator

KiranThomasCherian opened this issue · comments

You should try adding a future.delayed function which takes to the location screen after a delay and pass null as values.

This might help.

void getLocationData() async {
    var weatherData;
    Future.delayed(Duration(seconds: 15), () {
      if (weatherData == null) {
        Navigator.push(
            context,
            MaterialPageRoute(
                builder: (ctx) => LocationScreen(weatherData: null)));
      }
    });
    weatherData = await WeatherModel().getLocationWeather();

    Navigator.push(
        context,
        MaterialPageRoute(
            builder: (ctx) => LocationScreen(weatherData: weatherData)));
  }