getStatus method
Checks the current permission status, requests it if not granted, and shows a dialog if permanently denied.
Returns true if the permission is granted, false otherwise.
Deprecated — use CkPermission.camera.ensure instead:
final granted = await CkPermission.camera.ensure();
Implementation
@Deprecated('Use CkPermission.camera.ensure() instead.')
Future<bool> getStatus() async {
if (kIsWeb) return web_helper.requestWebPermission(permission);
var currentStatus = false;
final native = permission.resolveForPlatform(isAndroid: Platform.isAndroid);
currentStatus = (await native.status).isGranted;
if (!currentStatus) {
CkLogger.warning(
'Sorry! Current Permission Status is $currentStatus, need to take permission',
tag: 'Permission Handler',
);
final status = await native.request();
if (!status.isGranted) {
CkLogger.warning(
'Sorry! Permission ${permission.name} is ${status.name}',
tag: 'Permission Handler',
);
if (status.isPermanentlyDenied) {
_dialog();
}
return false;
}
}
return true;
}