From 5ad903da8ebeaa572423d5df43c4b56d3e97a908 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Thu, 8 Feb 2024 16:08:43 +0100 Subject: [PATCH] try other storage iOS --- lib/Components/cached_custom_resource.dart | 4 ++-- lib/Components/loading_common.dart | 2 +- lib/Screens/PDF/pdf_view.dart | 2 +- lib/main.dart | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Components/cached_custom_resource.dart b/lib/Components/cached_custom_resource.dart index 39ce796..618aaff 100644 --- a/lib/Components/cached_custom_resource.dart +++ b/lib/Components/cached_custom_resource.dart @@ -103,7 +103,7 @@ class CachedCustomResource extends StatelessWidget { Future _checkIfLocalResourceExists(TabletAppContext tabletAppContext) async { try { - Directory? appDocumentsDirectory = await getDownloadsDirectory(); + Directory? appDocumentsDirectory = Directory? appDocumentsDirectory = Platform.isIOS ? await getApplicationSupportDirectory() : await getDownloadsDirectory(); String localPath = appDocumentsDirectory!.path; Directory configurationDirectory = Directory('$localPath/${tabletAppContext.configuration!.id}'); List fileList = configurationDirectory.listSync(); @@ -121,7 +121,7 @@ class CachedCustomResource extends StatelessWidget { } Future get localPath async { - Directory? appDocumentsDirectory = await getDownloadsDirectory(); + Directory? appDocumentsDirectory = Platform.isIOS ? await getApplicationSupportDirectory() : await getDownloadsDirectory(); return appDocumentsDirectory!.path; } } diff --git a/lib/Components/loading_common.dart b/lib/Components/loading_common.dart index 79acdd9..d4afa3c 100644 --- a/lib/Components/loading_common.dart +++ b/lib/Components/loading_common.dart @@ -92,7 +92,7 @@ class _LoadingCommonState extends State with TickerProviderStateM Future _checkIfLocalResourceExists(TabletAppContext tabletAppContext, String resourceId) async { try { - Directory? appDocumentsDirectory = await getDownloadsDirectory(); + Directory? appDocumentsDirectory = Platform.isIOS ? await getApplicationSupportDirectory() : await getDownloadsDirectory(); String localPath = appDocumentsDirectory!.path; Directory configurationDirectory = Directory('$localPath/${tabletAppContext.configuration!.id}'); List fileList = configurationDirectory.listSync(); diff --git a/lib/Screens/PDF/pdf_view.dart b/lib/Screens/PDF/pdf_view.dart index ac5335d..e110278 100644 --- a/lib/Screens/PDF/pdf_view.dart +++ b/lib/Screens/PDF/pdf_view.dart @@ -167,7 +167,7 @@ class _PDFViewWidget extends State { Future _checkIfLocalResourceExists(TabletAppContext tabletAppContext, String resourceId) async { try { - Directory? appDocumentsDirectory = await getDownloadsDirectory(); + Directory? appDocumentsDirectory = Platform.isIOS ? await getApplicationSupportDirectory() : await getDownloadsDirectory(); String localPath = appDocumentsDirectory!.path; Directory configurationDirectory = Directory('$localPath/${tabletAppContext.configuration!.id}'); List fileList = configurationDirectory.listSync(); diff --git a/lib/main.dart b/lib/main.dart index eb24461..f9beb35 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,7 +25,7 @@ void main() async { localContext = await DatabaseHelper.instance.getData(); } - Directory? appDocumentsDirectory = await getDownloadsDirectory(); + Directory? appDocumentsDirectory = Platform.isIOS ? await getApplicationSupportDirectory() : await getDownloadsDirectory(); String localPath = appDocumentsDirectory!.path; if(localContext != null && localContext.host != null) {