retain method

void retain(
  1. Image image
)

Marks image as in use, which protects it from eviction until it is released with release as many times as it was retained.

This is a no-op when image does not belong to this cache. A clone of a cached image, made with Image.clone, retains the cached original.

Implementation

void retain(Image image) {
  final asset = _assetFor(image);
  if (asset == null) {
    return;
  }
  asset.refCount++;
  asset.lastUsed = clock.now();
}