requestPermission call on location object does not return on first call
See original GitHub issue_serviceEnabled = await location.serviceEnabled();
if (!_serviceEnabled) {
_serviceEnabled = await location.requestService();
if (!_serviceEnabled) {
return null;
}
}
_permissionGranted = await location.hasPermission();
if (_permissionGranted == PermissionStatus.denied) {
_permissionGranted = await location.requestPermission();//this is where execution goes to die
if (_permissionGranted != PermissionStatus.granted) {
return null;
}
Describe the bug I have the following code where I try to get location of the user. When this code is invoke for the very first time, the method requestPermission is where I get prompted on my phone for permission, when I press allowed, the method should return and execution continue.
It is worth noting that, if I do a hot reload during this perpetual wait, the request permission comes as granted (on this line _permissionGranted = await location.hasPermission()😉 without prompt.
Expected behavior When I allow permission on prompt, the program execution continue and the method requestMethod return a Future of PermissionStatus.
Tested on:
- Android, API Level 23, real device (Huawei)
- Not Tested On iOS
Following is my flutter doctor
Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18362.535], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) [√] Android Studio (version 3.6) [√] IntelliJ IDEA Community Edition (version 2018.1) [!] IntelliJ IDEA Ultimate Edition (version 2016.2) X Flutter plugin not installed; this adds Flutter specific functionality. X Dart plugin not installed; this adds Dart specific functionality. X This install is older than the minimum recommended version of 2017.1.0. [√] VS Code, 32-bit edition (version 1.43.2) [√] Connected device (1 available)
! Doctor found issues in 1 category.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:18 (1 by maintainers)
I also ran on API 28 PIXEL to same result.
I am using location: ^3.0.2
(Sorry about not putting the code in a code block above, for some reason, in a code block all the lines of code when being turned into one line)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.