我正在使用此Permission_handler软件包来使用存储权限。我想检查用户是否已经授予了权限,如果没有,我想向用户显示提示询问权限的提示。这是我的代码:
void checkPer() async {
PermissionStatus permission = await PermissionHandler()
.checkPermissionStatus(PermissionGroup.storage);
if (permission != PermissionStatus.granted ||
permission != PermissionStatus.restricted) {
Map<PermissionGroup, PermissionStatus> permissions =
await PermissionHandler()
.requestPermissions([PermissionGroup.storage]);
//print("permission request result is " + resReq.toString());
if (permissions[PermissionGroup.storage] == PermissionStatus.granted ||
permissions[PermissionGroup.storage] == PermissionStatus.restricted) {
// await downloadFile();
}
} else {
// await downloadFile();
}
}
问题是没有显示提示。有什么想法吗?