getPermission function
Future<bool>
getPermission(
- Permission permission, {
- required String alert,
- GestureTapCallback? cancelTap,
单独获取一个权限
Implementation
Future<bool> getPermission(
Permission permission, {
required String alert,
GestureTapCallback? cancelTap,
}) async {
if (!isMobile) return true;
PermissionStatus permissionStatus = await permission.status;
if (permissionStatus.isDenied) {
PermissionPrompt.show(content: alert);
permissionStatus = await permission.request();
pop();
}
if (!(permissionStatus.isGranted || permissionStatus.isLimited)) {
final result = await AlertConfirmCancel(
text: alert,
autoClose: false,
confirmTap: () {
pop(true);
},
cancelTap: () {
pop(false);
cancelTap?.call();
}).show();
if (result == true) await openAppSettings();
}
return permissionStatus.isGranted || permissionStatus.isLimited;
}