mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 08:31:19 +00:00
36 lines
1.1 KiB
Dart
36 lines
1.1 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:tablet_app/Models/tabletContext.dart';
|
|
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();
|
|
|
|
print(fileList);
|
|
|
|
if (fileList.isNotEmpty) {
|
|
File file = File(fileList.first.path);
|
|
print("FILE EXISTT");
|
|
return FileImage(file);
|
|
}
|
|
}
|
|
} catch(e) {
|
|
print("Error getImageProvider");
|
|
print(e.toString());
|
|
}
|
|
|
|
|
|
// If localpath not found or file missing
|
|
print("MISSINGG FILE");
|
|
return CachedNetworkImageProvider(imageSource);
|
|
}
|
|
}
|
|
|