flutter-geolocator
flutter-geolocator copied to clipboard
[Bug]: CheckPermission returns denied even if it is deniedForever
Please check the following before submitting a new issue.
- [ ] I have searched the existing issues.
- [X] I have carefully read the documentation 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
[✓] 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!
Related to https://github.com/Baseflow/flutter-permission-handler/issues/936
Related to Baseflow/flutter-permission-handler#936
Hi, I can see that the issue you mentioned is closed. Does the solution applied to this package as well?
Hi @HasanAlqaisi, unfortunately not yet. I'd like to get to it but have other priorities at this moment. If anyone in the community wants to pick this up that would be awesome. A great starting point would be to look at Baseflow/flutter-permission-handler#1130.
The bug is still there... Any news? (I have checked the PR)
checkPermission: LocationPermission.denied requestPermission: LocationPermission.deniedForever