This question is about permission handler package.
There are 2 methods in the library to check for a permission's status, for example in case of the microphone we can call:
PermissionStatus status1 = await Permission.microphone.status //call 1PermissionStatus status2 = await Permission.microphone.request() //call 2
suppose a user presses the 'dont ask again' when he is prompted to grant the permission. Now If:
- we make call 1 to get the permission status, we should expect to get
PermissionStatus.permanentlyDeniedbut the result isPermissionStatus.denied - we make call 2 to get the permission status, we expect to get
PermissionStatus.permanentlyDeniedand without the dialouge appearing again to the user, and this is exactly what happens
So call 2 works as intended but call 1 works as if there are only 2 states for a permission that can be returned from this call: granted or denied. But then how can we get the real status of the permission (for example it may be deniedPermanently) without calling request() in this case? Is this a bug or is this the intended behaviour? Sometimes I need to just check the status of the permission but I don't want to open a permission dialouge to the user, how to do that?
I will explain my use-case breifly:
I call the Permission.microphone.request() first time and then update my widget's state, then if the app (in android: activity) is paused, in the didChangeAppLifecycleState method which comes from the WidgetsBindingObserver mixin, I do check if the permission was revoked or permanently denied using Permission.microphone.status, but the problem is that this method is returning a denied status even when the permission is permanentlyDenied, and the correct return value which is permanentlyDenied is only returned if I call Permission.microphone.request()
code demo:
PermissionStatus result = await Permission.microphone.request();//this returns permanentlyDenied without opening the dialouge => ok
PermissionStatus result = await Permission.microphone.status;//this returns denied even if the status was permanently denied without opening the dialouge => NOT OK