flutter_auto_request method

Future<void> flutter_auto_request({
  1. required List<Permission> permissions,
})

Implementation

Future<void> flutter_auto_request({
  required List<Permission> permissions,
}) async {
  try {
    if (Dart.isWeb) {
      return;
    }

    if (Dart.isAndroid || Dart.isIOS || Dart.isWindows) {
      // await Permission.manageExternalStorage.isGranted;
      List<Permission> permission_datas = permissions;

      for (var i = 0; i < permission_datas.length; i++) {
        try {
          Permission permission = permission_datas[i];

          if (await permission.isPermanentlyDenied) {
            await openAppSettings();
          }

          if (await permission.isGranted) {
          } else {
            (await permission.request());
            continue;
          }
        } catch (e, stack) {
          if (kDebugMode) {
            print("${e} ${stack}");
          }
        }
      }
    }
  } catch (e) {}
}