ImageCache class

Class for the imageCache object.

Implements a least-recently-used cache of up to 1000 images, and up to 100 MB. The maximum size can be adjusted using maximumSize and maximumSizeBytes. Images that are actively in use (i.e. to which the application is holding references, either via ImageStream objects, ImageStreamCompleter objects, ImageInfo objects, or raw dart:ui.Image objects) may get evicted from the cache (and thus need to be refetched from the network if they are referenced in the putIfAbsent method), but the raw bits are kept in memory for as long as the application is using them.

The putIfAbsent method is the main entry-point to the cache API. It returns the previously cached ImageStreamCompleter for the given key, if available; if not, it calls the given callback to obtain it first. In either case, the key is moved to the "most recently used" position.

Generally this class is not used directly. The ImageProvider class and its subclasses automatically handle the caching of images.

Constructors

ImageCache()

Properties

currentSize int
The current number of cached entries.
read-only
currentSizeBytes int
The current size of cached entries in bytes.
read-only
maximumSize int
Maximum number of entries to store in the cache. [...]
read / write
maximumSizeBytes int
Maximum size of entries to store in the cache in bytes. [...]
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

clear() → void
Evicts all entries from the cache. [...]
evict(Object key) bool
Evicts a single entry from the cache, returning true if successful. [...]
putIfAbsent(Object key, ImageStreamCompleter loader()) ImageStreamCompleter
Returns the previously cached ImageStream for the given key, if available; if not, calls the given callback to obtain it first. In either case, the key is moved to the "most recently used" position. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited