Baseflow / flutter-permission-handler

Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
https://baseflow.com
MIT License
2.05k stars 861 forks source link

[Bug]: await Permission.location.request() returns PermissionStatus.denied when we answer approximate location. It only returns granted if we answer precise location #1384

Open ember11498 opened 2 months ago

ember11498 commented 2 months ago

Please check the following before submitting a new issue.

Please select affected platform(s)

Steps to reproduce

Very simple case there is no need.

Expected results

I expected to get true when user gives us approximate location.

Actual results

i get PermissionStatus.denied when user answers approximate location instead of precise location.

Code sample

  static Future<bool> requestLocation(BuildContext context) async {
    try {
      if (await Permission.location.isPermanentlyDenied) {
        if (context.mounted) {
          showDialogLocation(context);
        }
        return false;
      } else {
        final status = await Permission.location.request();
        return status.isGranted;
      }
    } catch (e) {
      print('Error requesting location permission: $e');
      return false;
    }
  }

Screenshots or video

No need

Version

11.0.1

Flutter Doctor output

[√] Flutter (Channel stable, 3.22.3, on Microsoft Windows [Version 10.0.22631.4169], locale pt-PT) • Flutter version 3.22.3 on channel stable at C:\src\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision b0850beeb2 (9 weeks ago), 2024-07-16 21:43:41 -0700 • Engine revision 235db911ba • Dart version 3.4.4 • DevTools version 2.34.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at C:\Users\35191\AppData\Local\Android\sdk • Platform android-34, build-tools 34.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java • Java version OpenJDK Runtime Environment (build 17.0.10+0--11572160) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.5.3) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.5.33516.290 • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2023.3) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.10+0--11572160)

[√] VS Code (version 1.93.1) • VS Code at C:\Users\35191\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.97.20240902

[√] Connected device (4 available) • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.4169] • Chrome (web) • chrome • web-javascript • Google Chrome 128.0.6613.138 • Edge (web) • edge • web-javascript • Microsoft Edge 129.0.2792.52

[√] Network resources • All expected network resources are available.

• No issues found!