askPermission static method
void
askPermission({
- required BuildContext context,
- required Function handle,
- required Permission permission,
Implementation
static void askPermission({
required BuildContext context,
required Function handle,
required Permission permission,
}) {
if (isAndroid) {
permission.status.then((value) {
if (value != PermissionStatus.granted) {
permission.request().then((value2) {
if (value == PermissionStatus.granted) {
handle();
}
});
} else {
handle();
}
});
} else if (isIOS) {
permission.status.then((value) {
debugPrint('Utils._askPermission $value');
if (value != PermissionStatus.granted) {
permission.request().then((value2) {
debugPrint('Utils.request $value2');
if (value2 == PermissionStatus.granted) {
handle();
} else {
Navigator.of(context, rootNavigator: true).push(PageRouteBuilder(
opaque: false,
pageBuilder: (BuildContext context, _, __) =>
guidePermissionView ?? GuidePermissionView(permission)));
}
});
} else if (value == PermissionStatus.granted) {
handle();
} else {
Navigator.of(context, rootNavigator: true).push(
PageRouteBuilder(
opaque: false,
pageBuilder: (BuildContext context, _, __) =>
guidePermissionView ?? GuidePermissionView(permission)),
);
}
});
}
}