release method

void release(
  1. Image image
)

Undoes one call to retain for image.

This is a no-op when image does not belong to this cache, which is also the case when it was cleared from the cache since it was retained.

Implementation

void release(Image image) {
  final asset = _assetFor(image);
  if (asset == null) {
    return;
  }
  assert(
    asset.refCount > 0,
    'Tried to release the image "${asset.key}" more times than it was '
    'retained',
  );
  if (asset.refCount > 0) {
    asset.refCount--;
  }
  asset.lastUsed = clock.now();
}