From a00606354468ace146e8fbf0a32dbff34c55f237 Mon Sep 17 00:00:00 2001 From: vibhutomer Date: Sat, 9 May 2026 15:09:59 +0530 Subject: [PATCH] fix: replace hardcoded android storage path with path_provider Signed-off-by: vibhutomer --- lib/utils/file_storage.dart | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/utils/file_storage.dart b/lib/utils/file_storage.dart index 5f53e8b51..eb9dff103 100644 --- a/lib/utils/file_storage.dart +++ b/lib/utils/file_storage.dart @@ -20,9 +20,21 @@ class FileStorage { await Permission.storage.request(); } Directory directory = Directory(""); + // if (Platform.isAndroid) { + // // Redirects it to download folder in android + // directory = Directory("/storage/emulated/0/Download"); + // } else { + // directory = await getApplicationDocumentsDirectory(); + // } if (Platform.isAndroid) { - // Redirects it to download folder in android - directory = Directory("/storage/emulated/0/Download"); + // Safely resolves the OS-provided external storage directory + final androidDir = await getExternalStorageDirectory(); + if (androidDir != null) { + directory = androidDir; + } else { + // Fallback if external storage is unavailable + directory = await getApplicationDocumentsDirectory(); + } } else { directory = await getApplicationDocumentsDirectory(); }