ScrollAwareImageProvider<T extends Object> class
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:
- If the returned ImageStream has been completed, end. This can happen if the caller sets the completer on the stream.
- 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.
- 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.
- 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.
- 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
-
- Object
- ImageProvider<
T> - ScrollAwareImageProvider
- Annotations
Constructors
-
ScrollAwareImageProvider({required DisposableBuildContext<
State< context, required ImageProvider<StatefulWidget> >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.
no setterinherited
-
imageProvider
→ ImageProvider<
T> -
The wrapped image provider to delegate obtainKey and loadImage to.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createStream(
ImageConfiguration configuration) → ImageStream -
Called by resolve to create the ImageStream it returns.
inherited
-
evict(
{ImageCache? cache, ImageConfiguration configuration = ImageConfiguration.empty}) → Future< bool> -
Evicts an entry from the image cache.
inherited
-
loadBuffer(
T key, DecoderBufferCallback decode) → ImageStreamCompleter -
Converts a key into an ImageStreamCompleter, and begins fetching the
image.
override
-
loadImage(
T key, ImageDecoderCallback decode) → ImageStreamCompleter -
Converts a key into an ImageStreamCompleter, and begins fetching the
image.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent 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.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