clearDiskCachedImage function

Future<bool> clearDiskCachedImage(
  1. String url, {
  2. String? cacheKey,
})

Clear the disk cache image then return if it succeed.

Implementation

Future<bool> clearDiskCachedImage(String url, {String? cacheKey}) async {
  try {
    final File? file = await getCachedImageFile(url, cacheKey: cacheKey);
    if (file != null) {
      await file.delete(recursive: true);
    }
  } catch (_) {
    return false;
  }
  return true;
}