isImageCached static method
Determines if an image file is cached based on the platform. it's not supported on web for now
On mobile platforms (Android and iOS), images are typically cached in temporary directories. This function helps identify whether the given image file path is a cached path on supported platforms.
imagePath
is the path of the image file to check for caching.
Returns true
if the image is cached, false
otherwise.
On other platforms it will always return false
Implementation
static bool isImageCached(String imagePath) {
// Determine if the image path is a cached path based on platform
if (kIsWeb) {
// For now this will not work for web
return false;
}
if (Platform.isAndroid) {
return imagePath.contains('cache');
}
if (Platform.isIOS) {
// Don't use isAppleOS() since macOS has different behavior
return imagePath.contains('tmp');
}
// On other platforms like desktop
// The image is not cached and we will get a direct
// access to the image
return false;
}