title: Flutter Geolocator - Ask if Denied, Device location, Refreshes on scroll
body: <p>Here is the code of my LocationWidget:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:android_intent/android_intent.dart';
  import 'package:geolocator/geolocator.dart';
  import 'package:location/location.dart' as prefix0;
  import 'package:provider/provider.dart';
  import 'package:shared_preferences/shared_preferences.dart';
  
  class CurrentLocationWidget extends StatefulWidget {
  
    final GlobalKey&lt;ScaffoldState&gt; scaffoldKey;
    CurrentLocationWidget({Key key, this.scaffoldKey}) : super(key: key);
  
    @override
    _LocationState createState() =&gt; _LocationState();
  }
  
  class _LocationState extends State&lt;CurrentLocationWidget&gt; {
  
    final Geolocator geolocator = Geolocator()..forceAndroidLocationManager;
  
    Position _currentPosition;
    String _currentAddress = '';
  
    @override
    void dispose() {
      // TODO: implement dispose
      super.dispose();
    }
    @override
    void initState() {
      _getCurrentLocation();
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      return FutureBuilder&lt;GeolocationStatus&gt;(
          future: geolocator.checkGeolocationPermissionStatus(),
          builder: (BuildContext context, AsyncSnapshot&lt;GeolocationStatus&gt; snapshot) {
            if (snapshot.data == GeolocationStatus.disabled || snapshot.data == null)
              {
                return Align(alignment: Alignment.centerLeft, child: Icon(Icons.location_off),);
              }
            else if (snapshot.data == GeolocationStatus.denied)
            {
              return Align(alignment: Alignment.centerLeft, child: Icon(Icons.location_off),);
            }
            else{
              return Center(
                child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: &lt;Widget&gt;[
                      Icon(Icons.location_on),
                      Text(_currentAddress)
                    ]
                ),
              );
            }
          });
    }
  
    _getCurrentLocation() async{
      geolocator
          .getCurrentPosition(desiredAccuracy: LocationAccuracy.best)
          .then((Position position) {
        setState(() {
          _currentPosition = position;
        });
        _getAddressFromLatLng();
      }).catchError((e) {
        print(e);
      });
    }
  
    _getAddressFromLatLng() async {
      try {
        //Logging current location to shared preferences
        SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
        sharedPreferences.setDouble("latitude", _currentPosition.latitude);
        sharedPreferences.setDouble("longitude", _currentPosition.longitude);
  
  
        List&lt;Placemark&gt; p = await geolocator.placemarkFromCoordinates(
            _currentPosition.latitude, _currentPosition.longitude);
  
        Placemark place = p[0];
  
        setState(() {
          _currentAddress =
          "${place.thoroughfare}";
        });
  
        // Update sign in and sign up locations
        if(sharedPreferences.getBool("SignUp")) {
          await updateUserSignUpLocation(context, _currentPosition.latitude, _currentPosition.longitude);
        }
        if(sharedPreferences.getBool("SignIn")) {
          await updateUserSignInLocation(context, _currentPosition.latitude, _currentPosition.longitude);
        }
      } catch (e) {
        print(e);
      }
    }
  
    Future&lt;Preferences&gt; updateUserSignUpLocation(BuildContext context, double latitude, double longitude) async {
      Api _api = Provider.of(context);
      UserTokenModel useTokenModelValue = await _api.getAccessToken();
      return await _api.updateUserSignUpData(useTokenModelValue.accessToken, latitude, longitude);
    }
  
    Future&lt;Preferences&gt; updateUserSignInLocation(BuildContext context, double latitude, double longitude) async {
      Api _api = Provider.of(context);
      UserTokenModel useTokenModelValue = await _api.getAccessToken();
      return await _api.updateUserSignInData(useTokenModelValue.accessToken, latitude, longitude);
    }
  
  }
  </code></pre>
  
  <p>How do I address the following issues:</p>
  
  <ol>
  <li><p>If the customer has "DENIED" the permission, then uses a location-dependent feature then I want to ask for permission again.</p></li>
  <li><p>If permission is "ALLOWED" then, I want to check if the device location is ON -> If it is OFF then I want to open the device settings.</p></li>
  <li><p>On-screen scroll, currently if permission is denied, then on scrolling the screen when the location-dependent widget is mounted it asks for the permission again. How can I stop that?</p></li>
  </ol>