pub trait ImageProvider: Debug + 'static {
// Required methods
fn key(&self, configuration: &ImageConfiguration) -> ImageCacheKey;
fn load_image(
&self,
app: &mut App,
key: &ImageCacheKey,
) -> Retained<Handle<ImageStreamCompleter>>;
// Provided method
fn resolve(
&self,
app: &mut App,
configuration: &ImageConfiguration,
) -> Retained<Handle<ImageStream>> { ... }
}Expand description
Something that can produce an image, and knows what identifies it. Flutter ImageProvider.
A provider is asked twice: once for the key that names its image in the cache, and once — only if nothing has it already — to start the decode. Keeping those apart is what lets several widgets showing the same picture share a single decode, and what lets a rebuilt widget paint an image that is already in memory without waiting a frame.
Required Methods§
Sourcefn key(&self, configuration: &ImageConfiguration) -> ImageCacheKey
fn key(&self, configuration: &ImageConfiguration) -> ImageCacheKey
What names this image in the cache. Flutter obtainKey.
Two requests for the same image must produce the same key, and two different images must never share one. Anything that changes the decoded pixels belongs in it, the scale included.
Sourcefn load_image(
&self,
app: &mut App,
key: &ImageCacheKey,
) -> Retained<Handle<ImageStreamCompleter>>
fn load_image( &self, app: &mut App, key: &ImageCacheKey, ) -> Retained<Handle<ImageStreamCompleter>>
Starts decoding, answering with the completer that will carry the frame. Flutter
loadImage.
Called only when the cache has neither the image nor a decode of it already running.
Provided Methods§
Sourcefn resolve(
&self,
app: &mut App,
configuration: &ImageConfiguration,
) -> Retained<Handle<ImageStream>>
fn resolve( &self, app: &mut App, configuration: &ImageConfiguration, ) -> Retained<Handle<ImageStream>>
The stream for this image, sharing whatever the cache already has. Flutter resolve.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".