flutter_cached_network_image
flutter_cached_network_image copied to clipboard
Cache not deleted after stalePeriod is passed
🐛 Bug Report
I am implementing a CustomCachemanager with a stalePeriod
of 1 minute to check if the cached data are deleted after the stale period passes. So far, it doesn't work and I don't know why. Any suggestion is welcome.
Expected behavior
The cached data are deleted after 1 minute.
Reproduction steps
- Created a CustomCacheManager
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
class CustomCacheManager extends CacheManager with ImageCacheManager {
factory CustomCacheManager() {
return _instance;
}
CustomCacheManager._()
: super(Config(key, stalePeriod: const Duration(minutes: 1)));
static const key = 'libCachedImageData';
static final CustomCacheManager _instance = CustomCacheManager._();
}
- Passed it in the CachedNetworkImage Constructor.
CachedNetworkImage(
imageUrl: imageUrl,
fit: BoxFit.cover,
cacheManager: CustomCacheManager(),
);
- Ran the app, the image is loaded from the network as it should.
- Terminate the app.
- re-ran the app and the image is loaded from the cache as it should
- Terminate the app and wait for some time (i.e.: 10 mins)
- Launch the app. At this point, I expect the image to be fetched from the network again since the cache should be deleted. Instead, the image is still fetched from the cache.
I used the flag CachedNetworkImage.logLevel = CacheManagerLogLevel.verbose;
Am I missing something here?
Configuration
Version: 3.3.1
Platform:
- Android 14