ScrollAwareImageProvider<T extends Object> class Null safety

An ImageProvider that makes use of Scrollable.recommendDeferredLoadingForContext to avoid loading images when rapidly scrolling.

This provider assumes that its wrapped imageProvider correctly uses the ImageCache, and does not attempt to re-acquire or decode images in the cache.

Calling resolve on this provider will cause it to obtain the image key and then check the following:

  1. If the returned ImageStream has been completed, end. This can happen if the caller sets the completer on the stream.
  2. If the ImageCache has a completer for the key for this image, ask the wrapped provider to resolve. This can happen if the image was precached, or another ImageProvider already resolved the same image.
  3. If the context has been disposed, end. This can happen if the caller has been disposed and is no longer interested in resolving the image.
  4. If the widget is scrolling with high velocity at this point in time, wait until the beginning of the next frame and go back to step 1.
  5. Delegate loading the image to the wrapped provider and finish.

If the cycle ends at steps 1 or 3, the ImageStream will never be marked as complete and listeners will not be notified.

The Image widget wraps its incoming providers with this provider to avoid overutilization of resources for images that would never appear on screen or only be visible for a very brief period.

Inheritance
Annotations

Constructors

ScrollAwareImageProvider({required DisposableBuildContext<State<StatefulWidget>> context, required ImageProvider<T> imageProvider})
Creates a ScrollAwareImageProvider. [...]
const

Properties

context DisposableBuildContext<State<StatefulWidget>>
The context that may or may not be enclosed by a Scrollable. [...]
final
hashCode int
The hash code for this object. [...]
read-only, inherited
imageProvider ImageProvider<T>
The wrapped image provider to delegate obtainKey and load to.
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

createStream(ImageConfiguration configuration) ImageStream
Called by resolve to create the ImageStream it returns. [...]
@protected, inherited
evict({ImageCache? cache, ImageConfiguration configuration = ImageConfiguration.empty}) Future<bool>
Evicts an entry from the image cache. [...]
inherited
load(T key, DecoderCallback decode) ImageStreamCompleter
Converts a key into an ImageStreamCompleter, and begins fetching the image. [...]
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
obtainCacheStatus({required ImageConfiguration configuration, ImageErrorListener? handleError}) Future<ImageCacheStatus?>
Returns the cache location for the key that this ImageProvider creates. [...]
inherited
obtainKey(ImageConfiguration configuration) Future<T>
Converts an ImageProvider's settings plus an ImageConfiguration to a key that describes the precise image to load. [...]
override
resolve(ImageConfiguration configuration) ImageStream
Resolves this image provider using the given configuration, returning an ImageStream. [...]
@nonVirtual, inherited
resolveStreamForKey(ImageConfiguration configuration, ImageStream stream, T key, ImageErrorListener handleError) → void
Called by resolve with the key returned by obtainKey. [...]
override
toString() String
A string representation of this object. [...]
inherited

Operators

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