add method
Path prefix to the project's directory with images.
This path is relative to the project's root, and the default prefix is "assets/images/". If necessary, you may change this prefix at any time. A prefix must be a valid directory name and end with "/" (empty prefix is also allowed).
The prefix is not part of the keys of the images stored in this cache.
For example, if you load image player.png
, then it will be searched at
location prefix + "player.png"
but stored in the cache under the key
"player.png"
.
Adds the image
into the cache under the key name
.
The cache will assume the ownership of the image
, and will properly
dispose of it at the end.
Implementation
/// Adds the [image] into the cache under the key [name].
///
/// The cache will assume the ownership of the [image], and will properly
/// dispose of it at the end.
void add(String name, Image image) {
_assets[name]?.dispose();
_assets[name] = _ImageAsset.fromImage(image);
}