deleteCachedImage static method

Future<void> deleteCachedImage({
  1. required String imageUrl,
  2. bool showLog = true,
})

deleteCachedImage function takes in a image imageUrl and removes the image corresponding to the url from the cache if the image is present in the cache.

Implementation

static Future<void> deleteCachedImage(
    {required String imageUrl, bool showLog = true}) async {
  _checkInit();

  final key = _keyFromUrl(imageUrl);
  if (_imageKeyBox!.keys.contains(key) && _imageBox!.keys.contains(key)) {
    await _imageKeyBox!.delete(key);
    await _imageBox!.delete(key);
    if (showLog) {
      debugPrint('FastCacheImage: Removed image $imageUrl from cache.');
    }
  }
}