diff --git a/cached_network_image/lib/src/cached_image_widget.dart b/cached_network_image/lib/src/cached_image_widget.dart index a23192db..fb164cf4 100644 --- a/cached_network_image/lib/src/cached_image_widget.dart +++ b/cached_network_image/lib/src/cached_image_widget.dart @@ -55,7 +55,7 @@ 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 d853c535..7aacf903 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 DefaultCacheManager defaultCacheManager = DefaultCacheManager(); + /// Web url of the image to load final String url; @@ -113,7 +116,7 @@ class CachedNetworkImageProvider cacheKey, chunkEvents, decode, - cacheManager ?? DefaultCacheManager(), + cacheManager ?? defaultCacheManager, maxHeight, maxWidth, headers, @@ -166,7 +169,7 @@ class CachedNetworkImageProvider cacheKey, chunkEvents, decode, - cacheManager ?? DefaultCacheManager(), + cacheManager ?? defaultCacheManager, maxHeight, maxWidth, headers,