Skip to content

Commit

Permalink
Merge pull request #933 from AurelVU/develop
Browse files Browse the repository at this point in the history
added static field defaultCacheManager to CachedNetworkImageProvider
  • Loading branch information
martijn00 authored Jul 31, 2024
2 parents a05e39d + e3763e1 commit c5c650f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cached_network_image/lib/src/cached_image_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -110,7 +113,7 @@ class CachedNetworkImageProvider
cacheKey,
chunkEvents,
decode,
cacheManager ?? DefaultCacheManager(),
cacheManager ?? defaultCacheManager,
maxHeight,
maxWidth,
headers,
Expand Down Expand Up @@ -160,7 +163,7 @@ class CachedNetworkImageProvider
cacheKey,
chunkEvents,
decode,
cacheManager ?? DefaultCacheManager(),
cacheManager ?? defaultCacheManager,
maxHeight,
maxWidth,
headers,
Expand Down

0 comments on commit c5c650f

Please sign in to comment.