diff --git a/cached_network_image/lib/src/cached_image_widget.dart b/cached_network_image/lib/src/cached_image_widget.dart index a23192db..2de02658 100644 --- a/cached_network_image/lib/src/cached_image_widget.dart +++ b/cached_network_image/lib/src/cached_image_widget.dart @@ -55,7 +55,8 @@ class CachedNetworkImage extends StatelessWidget { BaseCacheManager? cacheManager, double scale = 1, }) async { - final effectiveCacheManager = cacheManager ?? DefaultCacheManager(); + final effectiveCacheManager = + cacheManager ?? CachedNetworkImageProvider.defaultCacheManager; await effectiveCacheManager.removeFile(cacheKey ?? url); return CachedNetworkImageProvider(url, scale: scale).evict(); } diff --git a/cached_network_image/lib/src/image_provider/cached_network_image_provider.dart b/cached_network_image/lib/src/image_provider/cached_network_image_provider.dart index e4b68ac6..37245758 100644 --- a/cached_network_image/lib/src/image_provider/cached_network_image_provider.dart +++ b/cached_network_image/lib/src/image_provider/cached_network_image_provider.dart @@ -34,6 +34,9 @@ class CachedNetworkImageProvider /// CacheManager from which the image files are loaded. final BaseCacheManager? cacheManager; + /// The default cache manager used for image caching. + static BaseCacheManager defaultCacheManager = DefaultCacheManager(); + /// Web url of the image to load final String url; @@ -110,7 +113,7 @@ class CachedNetworkImageProvider cacheKey, chunkEvents, decode, - cacheManager ?? DefaultCacheManager(), + cacheManager ?? defaultCacheManager, maxHeight, maxWidth, headers, @@ -160,7 +163,7 @@ class CachedNetworkImageProvider cacheKey, chunkEvents, decode, - cacheManager ?? DefaultCacheManager(), + cacheManager ?? defaultCacheManager, maxHeight, maxWidth, headers,