flutter_cached_network_image icon indicating copy to clipboard operation
flutter_cached_network_image copied to clipboard

Cache not deleted after stalePeriod is passed

Open aggeloskoutanis opened this issue 3 months ago • 0 comments

🐛 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

  1. 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._();
}
  1. Passed it in the CachedNetworkImage Constructor.
   CachedNetworkImage(
      imageUrl: imageUrl,
      fit: BoxFit.cover,
      cacheManager: CustomCacheManager(),
    );
  1. Ran the app, the image is loaded from the network as it should.
  2. Terminate the app.
  3. re-ran the app and the image is loaded from the cache as it should
  4. Terminate the app and wait for some time (i.e.: 10 mins)
  5. 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

aggeloskoutanis avatar May 20 '24 10:05 aggeloskoutanis