Baseflow / Baseflow/flutter-geolocator

[Bug]: CheckPermission returns denied even if it is deniedForever

Open
#1,316 4 comments 6 reactions 0 assignees View on GitHub
P2 platform: android type: bug
Dominant language
Dart
Stars
1.3k
Forks
803
Avg merge
8h 16m
Merged PRs (30d)
1

Description

### Please check the following before submitting a new issue.

- [ ] I have searched the [existing issues](https://github.com/baseflow/flutter-geolocator/issues).
- [X] I have carefully [read the documentation](https://github.com/Baseflow/flutter-geolocator/blob/main/geolocator/README.md) and verified I have added the required platform specific configuration.

### Please select affected platform(s)

- [X] Android (13)
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [ ] Windows

### Steps to reproduce

For the first time I call Geolocator.checkPermission() and it returns denied then I call Geolocator.requestPermission().
If the user pressed don't allow, requestPermission will return deniedForever.
But the issue is when checking again with Geolocator.checkPermission() it returns denied and not deniedForever.

### Expected results

Geolocator.checkPermission() should return deniedForever when the user had clicked don't allow before.

### Actual results

denied instead of deniedForever

### Code sample

Code Sample

```
var status = await Geolocator.checkPermission();

if (status == PermissionStatus.deniedForever) {
return null;
}

if (status == PermissionStatus.denied) {
await _showWhyWeNeedLocation();

status = await Geolocator.requestPermission();
}

if (status == PermissionStatus.denied ||
status == PermissionStatus.deniedForever) return null;

var isLocationEnabled = await Geolocator.isLocationServiceEnabled();

if (isLocationEnabled) return await Geolocator.getCurrentPosition();

await _askToEnableLocation();
await Geolocator.openLocationSettings()
isLocationEnabled = await Geolocator.isLocationServiceEnabled();

if (isLocationEnabled) {
return await Geolocator.getCurrentPosition();;
} else {
return null;
}
```

### Screenshots or video

_No response_

### Version

10.0.0

### Flutter Doctor output

Doctor output

```console
[✓] Flutter (Channel stable, 3.10.5, on Linux Mint 21.2 5.15.0-82-generic,
locale en_US.UTF-8)
• Flutter version 3.10.5 on channel stable at
/home/hasan/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 796c8ef792 (3 months ago), 2023-06-13 15:51:02 -0700
• Engine revision 45f6e00911
• Dart version 3.0.5
• DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /home/hasan/Android/Sdk
• Platform android-33-ext4, build-tools 33.0.2
• Java binary at: /home/hasan/development/android-studio/jbr/bin/java
• Java version OpenJDK Runtime Environment (build
11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.

[✓] Chrome - develop for the web
• Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
• clang version 13.0.0 (https://github.com/apple/llvm-project.git
c41f13252ed4b49f246729b4d91ff521d5a6bf9d)
• cmake version 3.22.1
• ninja version 1.10.1
• pkg-config version 0.29.2

[✓] Android Studio (version 2022.1)
• Android Studio at /home/hasan/development/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
11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.81.1)
• VS Code at /usr/share/code
• Flutter extension version 3.70.0

[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Linux Mint 21.2
5.15.0-82-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 116.0.5845.110

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

• No issues found!

```

Contributor guide

Open the contributing guide

Research direction

Start by tracing the Android implementation behind Geolocator.checkPermission() and requestPermission(), using the reported Android 13 flow as the reproduction case. Verify that after requestPermission() returns deniedForever, a subsequent checkPermission() also returns deniedForever, and cover the reported behavior with an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, dart, flutter
Domain
mobile-dev, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.