From a7a3aeecc527aa215c0d22d5476546470c3f5361 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 1 Dec 2023 14:05:06 +0200 Subject: [PATCH] Fix for documents on iOS --- lib/utils/files.dart | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/utils/files.dart b/lib/utils/files.dart index 3469a4a94a..b3e1f64b00 100644 --- a/lib/utils/files.dart +++ b/lib/utils/files.dart @@ -40,15 +40,21 @@ Future?> pickFiles({ allowMultiple: allowMultiple, ); } else { - final androidInfo = await DeviceInfoPlugin().androidInfo; - PermissionStatus status; + PermissionStatus? status; - if (Platform.isIOS && fileType == FileType.image) { - status = await Permission.photos.request(); - } else if (Platform.isAndroid && androidInfo.version.sdkInt >= 33) { - status = await Permission.photos.request(); - } else { - status = await Permission.storage.request(); + if (Platform.isIOS) { + if (fileType == FileType.image) { + status = await Permission.photos.request(); + } else { + status = await Permission.storage.request(); + } + } else if (Platform.isAndroid) { + final androidInfo = await DeviceInfoPlugin().androidInfo; + if (androidInfo.version.sdkInt >= 33) { + status = await Permission.photos.request(); + } else { + status = await Permission.storage.request(); + } } if (status == PermissionStatus.granted) {