1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] How to request user for precise location?

Discussão em 'Mobile' iniciado por Stack, Outubro 1, 2024 às 00:42.

  1. Stack

    Stack Membro Participativo

    Using Geolocator package, when requesting location permission user can select for approximate location. Or user can also turn off precise location from settings. We can get location accuracy that user has selected from -> (LocationAccuracyStatus.reduced || LocationAccuracyStatus.precise) but how to request user again for precise location permission?

    So initially if approximate location permissions are granted, then after checking LocationAccuracyStatus value is reduced, I called Geolocator.requestPermission() again but it did not show system ui popup again.

    LocationPermission permission;
    permission = await Geolocator.checkPermission();
    if (permission == LocationPermission.denied) {
    permission = await Geolocator.requestPermission();
    if (permission == LocationPermission.denied) {
    MainUtils.showTopSnackbar(
    "Location Permissions are required to use the app",
    duration: const Duration(seconds: 5));
    return;
    }
    }

    //CHECKING LOCATION ACCURACY
    var accuracy = await Geolocator.getLocationAccuracy();
    if (accuracy == LocationAccuracyStatus.reduced) {
    permission = await Geolocator.requestPermission(); //REQUESTING PERMISSION AGAIN
    }


    https://developer.android.com/develop/sensors-and-location/location/permissions#upgrade-to-precise


    Reference image

    Continue reading...

Compartilhe esta Página