After upgrading PermissionHandler
to latest (5.0.0). The PermissionHandler()
not found and also
The name 'PermissionGroup' isn't a type so it can't be used as a type argument.
.
Here is a code snippet:
PermissionStatus permission = await PermissionHandler().checkPermissionStatus(PermissionGroup.storage);
if (permission != PermissionStatus.granted && permission != PermissionStatus.neverAskAgain) {
Map<PermissionGroup, PermissionStatus> permissions = await PermissionHandler().requestPermissions([PermissionGroup.storage]);
if (permissions.containsValue(2))
fileDownload(context, finalUrl);
}
What is the problem?
That because from permission_handler: ^5.0.0
the author BaseFlow made it more intuitive for us to use
as asked in this issue ticker (#230).
Your code snippet need to change like below:
if (await Permission.storage.request().isGranted) {
fileDownload(context, finalUrl);
}
So now those mapped like this:
old way new way
------- -------
await PermissionHandler()
.checkPermissionStatus(PermissionGroup.camera) await PermissionGroup.camera.status
await PermissionHandler().requestPermissions(
[PermissionGroup.camera]))[PermissionGroup.camera] await PermissionGroup.camera.request()
await PermissionHandler().requestPermissions(
[PermissionGroup.camera, PermissionGroup.storage])) await [PermissionGroup.camera, PermissionGroup.storage].request()
await PermissionHandler().checkServiceStatus
(PermissionGroup.location) await Permission.location.serviceStatus.isEnabled
Read more here: this issue ticker (#230).
Use permission_handler: ^3.0.0 ,it Worked for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With