fromCache method

Image fromCache(
  1. String name
)

Returns the image name from the cache.

The image returned can be used as long as it remains in the cache, but doesn't need to be explicitly disposed.

If you want to retain the image even after you remove it from the cache, then you can call Image.clone() on it.

Implementation

Image fromCache(String name) {
  final asset = _assets[name];
  assert(
    asset != null,
    'Tried to access an image "$name" that does not exist in the cache. Make '
    'sure to load() an image before accessing it',
  );
  assert(
    asset!.image != null,
    'Tried to access an image "$name" before it was loaded. Make sure to '
    'await the future from load() before using this method',
  );
  return asset!.image!;
}