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 getImageProvider(AppContext appContext, String imageId, String imageSource) { TabletAppContext tabletAppContext = appContext.getContext(); if(appContext.getContext().localPath != null && tabletAppContext.configuration != null) { Directory configurationDirectory = Directory('${tabletAppContext.localPath!}/${tabletAppContext.configuration!.id!}'); List fileList = configurationDirectory.listSync(); print(fileList); if (fileList.isNotEmpty) { File file = File(fileList.first.path); print("FILE EXISTT"); return FileImage(file); } } // If localpath not found or file missing print("MISSINGG FILE"); return CachedNetworkImageProvider(imageSource); } }