fxCanAccessGallery function

Future<bool> fxCanAccessGallery()

Implementation

Future<bool> fxCanAccessGallery() async {
  bool useStoragePermission = false;
  if (Platform.isAndroid) {
    final androidInfo = await DeviceInfoPlugin().androidInfo;
    final androidVersion = androidInfo.version.sdkInt;

    if (androidVersion <= 32) {
      useStoragePermission = true;
      await Permission.storage.request();
    }
  }

  await Permission.photos.request();

  PermissionStatus galleryPermission;
  if (useStoragePermission) {
    galleryPermission = await Permission.storage.status;
  } else {
    galleryPermission = await Permission.photos.status;
  }

  if (galleryPermission == PermissionStatus.granted) {
    return true;
  }

  return false;
}