requestPermission does not resolve any return value
Describe the bug I am triggering the requestPermission function from inside an AlertDialog and am not getting any response from the request function, eventho the system dialog is showing and permissions can be approved and then used by the app.
I have tried to use it as async/await function and future with the same result, no return value is received by the code.
Expected behavior The function returns the correct result based on the user action on the system permission dialog.
Tested on: Android Redmi Note 8 Pro API 28
Code implementation
FlatButton(
onPressed: () async {
Location _locationPointer = new Location();
PermissionStatus permissionResult = await _locationPointer.requestPermission();
if (permissionResult == PermissionStatus.GRANTED) {
Navigator.of(context, rootNavigator: true).pop('dialog');
});
},
child: Text(
'Allow',
style: TextStyle(color: Color.fromRGBO(23, 148, 57, 1)),
),
)
Hey ! Does it works outside of the FlatButton ? There is nothing different that I can see. Do you have any log to give ?
@Lyokone I have added this code into my widgets build method to test now:
debugPrint('[DEBUG] Request permission');
_locationPointer
.requestPermission()
.then((PermissionStatus permissionResult) {
debugPrint(
'[DEBUG] permission result: ' + permissionResult.toString());
if (permissionResult == PermissionStatus.GRANTED) {
debugPrint('[DEBUG] permission granted');
} else {
debugPrint("[DEBUG] permission denied");
}
});
The same result can be observed with the future never resolving. In terms of logs my first debug print gets fired and after that the app isn't doing anything since it is waiting for the future to resolve. So this is what I see in the console:
I/flutter ( 5318): [DEBUG] Request permission
W/.( 5318): JNI critical lock held for 19.365ms on Thread[1,tid=5318,Runnable,Thread*=0xe885c000,peer=0x752e2f60,"main"]
W/.( 5318): JNI critical lock held for 27.920ms on Thread[1,tid=5318,Runnable,Thread*=0xe885c000,peer=0x752e2f60,"main"]
W/.( 5318): JNI critical lock held for 22.532ms on Thread[1,tid=5318,Runnable,Thread*=0xe885c000,peer=0x752e2f60,"main"]
This time tested on pixel 3 emulator API 28 as well.
I have checked on 2.5.3 version and it doesn't work either on Flutter dev or stable channel. It is only happening when dialog is displayed (first opening of widget). On second and latter times when permission is already granted method work fluently :)
I have the same problem, method requestPermissions() does not return result.
Same issue here, requestPermission() does not return anything.
Same here. Future never returns result :(
Hey, I'll try to look into this, but I haven't been able to reproduce the bug easily for now :/
I created a new project and it's working there(same code). So maybe it's a problem on how it integrates with older projects(mine is around 4 months old).
@Lyokone I think the problem is at the end of the requestPermissions() function in the FlutterLocation.java file, which is not passing any result.success() after the ActivityCompat.requestPermissions() function. The same thing happens in the requestService() function.
I created a new project and transferred my files there and it worked normally hahaha
Great I'll close this thanks :)
Great I'll close this thanks :)
What? Why closed? there is the problem. after system dialog about granting permissions all functions of plugin don't return any response. only after the second entry in the app the plugin start work
Any updates on this? I am still facing this issue! @Lyokone