mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 08:31:19 +00:00
Added try catch file access
This commit is contained in:
parent
cdda7d1470
commit
387560fad7
@ -102,6 +102,7 @@ class CachedCustomResource extends StatelessWidget {
|
||||
}
|
||||
|
||||
Future<File?> _checkIfLocalResourceExists(TabletAppContext tabletAppContext) async {
|
||||
try {
|
||||
Directory? appDocumentsDirectory = await getDownloadsDirectory();
|
||||
String localPath = appDocumentsDirectory!.path;
|
||||
Directory configurationDirectory = Directory('$localPath/${tabletAppContext.configuration!.id}');
|
||||
@ -111,6 +112,10 @@ class CachedCustomResource extends StatelessWidget {
|
||||
File file = File(fileList.firstWhere((fileL) => fileL.uri.pathSegments.last.contains(resourceDTO.id!)).path);
|
||||
return file;
|
||||
}
|
||||
} catch(e) {
|
||||
print("ERROR _checkIfLocalResourceExists CachedCustomResource");
|
||||
print(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:tablet_app/app_context.dart';
|
||||
class ImageCustomProvider {
|
||||
static ImageProvider<Object> getImageProvider(AppContext appContext, String imageId, String imageSource) {
|
||||
TabletAppContext tabletAppContext = appContext.getContext();
|
||||
try {
|
||||
if(appContext.getContext().localPath != null && tabletAppContext.configuration != null) {
|
||||
Directory configurationDirectory = Directory('${tabletAppContext.localPath!}/${tabletAppContext.configuration!.id!}');
|
||||
List<FileSystemEntity> fileList = configurationDirectory.listSync();
|
||||
@ -20,6 +21,11 @@ class ImageCustomProvider {
|
||||
return FileImage(file);
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
print("Error getImageProvider");
|
||||
print(e.toString());
|
||||
}
|
||||
|
||||
|
||||
// If localpath not found or file missing
|
||||
print("MISSINGG FILE");
|
||||
|
||||
@ -165,6 +165,7 @@ class _PDFViewWidget extends State<PDFViewWidget> {
|
||||
} //_webView
|
||||
|
||||
Future<File?> _checkIfLocalResourceExists(TabletAppContext tabletAppContext, String resourceId) async {
|
||||
try {
|
||||
Directory? appDocumentsDirectory = await getDownloadsDirectory();
|
||||
String localPath = appDocumentsDirectory!.path;
|
||||
Directory configurationDirectory = Directory('$localPath/${tabletAppContext.configuration!.id}');
|
||||
@ -174,6 +175,10 @@ Future<File?> _checkIfLocalResourceExists(TabletAppContext tabletAppContext, Str
|
||||
File file = File(fileList.firstWhere((fileL) => fileL.uri.pathSegments.last.contains(resourceId)).path);
|
||||
return file;
|
||||
}
|
||||
} catch (e) {
|
||||
print("ERROR _checkIfLocalResourceExists PDF");
|
||||
print(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user