From 0a639ae9f5aa633f377f46bd16894a40c4c43f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A3=D1=88=D0=B0=D0=BA=D0=BE=D0=B2=20=D0=92=D0=BB=D0=B0?= =?UTF-8?q?=D0=B4=D0=B8=D0=BC=D0=B8=D1=80?= Date: Wed, 27 Mar 2024 11:49:39 +0300 Subject: [PATCH] added static field defaultCacheManager to CachedNetworkImageProvider --- cached_network_image/lib/src/cached_image_widget.dart | 2 +- .../src/image_provider/cached_network_image_provider.dart | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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,