checkPermission static method

Future<bool> checkPermission(
  1. BuildContext context,
  2. int value, [
  3. TUITheme? theme,
  4. bool isShowPermissionPage = true,
])

Implementation

static Future<bool> checkPermission(
    BuildContext context,
    int value, [
      TUITheme? theme,
      bool isShowPermissionPage = true,
    ]) async {
  final status = await Permission.byValue(value).status;
  if (status.isGranted || status.isLimited) {
    return true;
  }
  final bool? shouldRequestPermission = await showPermissionConfirmDialog(
    context,
    value,
    theme,
    isShowPermissionPage,
  );
  if (shouldRequestPermission != null && shouldRequestPermission) {
    final isGranted = await Permission.byValue(value).request().isGranted;
    _entry?.remove();
    _entry = null;
    return isGranted;
  }
  return shouldRequestPermission ?? false;
}