Baseflow / Baseflow/flutter-geolocator

[Bug]: Geolocator.requestPermission() returns not actual status in Android 30 and above

Open
#1,388 3 comments 1 reaction 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.

- [X] 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
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [ ] Windows

### Steps to reproduce

1. Geolocator.requestPermission(), select Allow only while using the app
2. Go to app's permission settings and change to Allow all the time.
3. Geolocator.requestPermission() again.

### Expected results

Geolocator.requestPermission() should return actual status after manually changing the permission in settings, or in any other context.

### Actual results

Geolocator.requestPermission() returns not actual status after manually changing the permission in settings.

### Code sample

Code sample

```dart
await Geolocator.requestPermission();// select Allow while in use
await BackgroundLocation.startLocationService(distanceFilter: 10); // asks to change to Allow all the time.
final status = await Geolocator.requestPermission(); // in here it is while in use status
```

### Screenshots or video

Screenshots or video demonstration

[Upload media here]

### Version

10.1.0

### Flutter Doctor output

Doctor output

```console
[✓] Flutter (Channel stable, 3.16.2, on macOS 13.5.1 22G90 darwin-x64, locale en-GB)
• Flutter version 3.16.2 on channel stable at /Library/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 9e1c857886 (30 hours ago), 2023-11-30 11:51:18 -0600
• Engine revision cf7a9d0800
• Dart version 3.2.2
• DevTools version 2.28.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/nzakoyan/Library/Android/sdk
• Platform android-33, build-tools 30.0.3
• ANDROID_HOME = /Users/nzakoyan/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A240d
• CocoaPods version 1.11.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
• Android Studio at /Applications/Android Studio.app/Contents
• 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.6+0-17.0.6b829.9-10027231)

[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• 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

[✓] Connected device (4 available)
• Redmi S2 (mobile) • 1493d35 • android-arm • Android 9 (API 28)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator)
• macOS (desktop) • macos • darwin-x64 • macOS 13.5.1 22G90 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 119.0.6045.199

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

• No issues found!

```

Contributor guide

Open the contributing guide

Research direction

Start at the Geolocator.requestPermission() entry point and reproduce the Android 30+ sequence: grant while-in-use access, change to all-time access in settings, then request permission again. Compare the returned status with the setting after the second request. Done means requestPermission() reports the permission currently configured in Android settings.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.