evict method

bool evict (Object key)

Evicts a single entry from the cache, returning true if successful. Pending images waiting for completion are removed as well, returning true if successful.

When a pending image is removed the listener on it is removed as well to prevent it from adding itself to the cache if it eventually completes.

The key must be equal to an object used to cache an image in ImageCache.putIfAbsent.

If the key is not immediately available, as is common, consider using ImageProvider.evict to call this method indirectly instead.

See also:


bool evict(Object key) {
  final _PendingImage pendingImage = _pendingImages.remove(key);
  if (pendingImage != null) {
    return true;
  final _CachedImage image = _cache.remove(key);
  if (image != null) {
    _currentSizeBytes -= image.sizeBytes;
    return true;
  return false;