Skip to main content

ImageStreamCompleter

Struct ImageStreamCompleter 

Source
pub struct ImageStreamCompleter { /* private fields */ }
Expand description

The resolving half of an image: holds the frame once it exists and tells the listeners.

Flutter ImageStreamCompleter. A listener added after the image has arrived is called straight away, which is what lets a widget built later show a cached image in its first frame instead of flashing empty.

Implementations§

Source§

impl ImageStreamCompleter

Source

pub fn new(app: &mut App) -> Retained<Handle<ImageStreamCompleter>>

Creates a completer with no image yet.

Source

pub fn keep_alive( self: Handle<ImageStreamCompleter>, app: &mut App, ) -> ImageStreamCompleterHandle

Holds this completer without subscribing to its frames.

Source

pub fn add_on_last_listener_removed_callback( self: Handle<ImageStreamCompleter>, app: &mut App, callback: Listener, )

Registers cleanup when the last frame listener leaves. Callbacks are cleared afterward.

Source

pub fn remove_on_last_listener_removed_callback( self: Handle<ImageStreamCompleter>, app: &mut App, callback: &Listener, )

Unregisters a previously installed last-listener callback.

Source

pub fn maybe_dispose(self: Handle<ImageStreamCompleter>, app: &mut App)

Releases resources once neither listeners nor keep-alive handles need this completer.

Source

pub fn current_image( self: Handle<ImageStreamCompleter>, app: &App, ) -> Option<ImageInfo>

The frame this completer holds, if one has arrived.

Source

pub fn current_error( self: Handle<ImageStreamCompleter>, app: &App, ) -> Option<ImageDecodeError>

Why this image will never arrive, if it failed.

Source

pub fn listener_count(self: Handle<ImageStreamCompleter>, app: &App) -> usize

How many listeners are waiting, which is what tells the cache whether anyone still wants this image.

Source

pub fn set_on_watched( self: Handle<ImageStreamCompleter>, app: &mut App, on_watched: Rc<dyn Fn(&mut App, bool)>, )

Watches whether anyone is listening, so work nobody is waiting for can be stopped.

Called with true when the first listener arrives and false when the last one leaves. An animation uses this to stop between frames while it is off screen and pick up again when it comes back; Dart’s completer overrides its listener methods to the same end.

Source

pub fn add_listener( self: Handle<ImageStreamCompleter>, app: &mut App, listener: ImageStreamListener, )

Adds a listener, calling it at once if the image or the failure is already here.

Source

pub fn remove_listener( self: Handle<ImageStreamCompleter>, app: &mut App, listener: &ImageStreamListener, )

Removes a listener added with add_listener.

Source

pub fn set_image( self: Handle<ImageStreamCompleter>, app: &mut App, image: ImageInfo, )

Hands a frame to every listener and keeps it for listeners still to come.

Source

pub fn report_image_chunk_event( self: Handle<ImageStreamCompleter>, app: &mut App, event: ImageChunkEvent, )

Tells every listener with a chunk callback about bytes that arrived. Flutter reportImageChunkEvent.

Source

pub fn report_error( self: Handle<ImageStreamCompleter>, app: &mut App, error: ImageDecodeError, )

Tells every listener that the image failed, and keeps the failure for later listeners.

Trait Implementations§

Source§

impl Default for ImageStreamCompleter

Source§

fn default() -> ImageStreamCompleter

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for ImageStreamCompleter

§

impl !Send for ImageStreamCompleter

§

impl !Sync for ImageStreamCompleter

§

impl !UnwindSafe for ImageStreamCompleter

§

impl Forget for ImageStreamCompleter

§

impl Freeze for ImageStreamCompleter
where *const u8 is !null: Freeze, PhantomData<ImageStreamListener>: Freeze, *const ArcInner<ImageInner> is !null: Freeze, PhantomData<ArcInner<ImageInner>>: Freeze, PhantomData<u8>: Freeze, *const RcInner<dyn Fn(&mut App, bool)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, bool)>>: Freeze, PhantomData<Listener>: Freeze, *const RcInner<dyn Fn(&mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze, NonZero<u32>: Freeze, *const (): Freeze,

§

impl Move for ImageStreamCompleter

§

impl Unpin for ImageStreamCompleter
where *const u8 is !null: Unpin, Rc<dyn Fn(&mut App, &ImageInfo, bool)>: Unpin, Rc<dyn Fn(&mut App, &ImageChunkEvent)>: Unpin, Rc<dyn Fn(&mut App, &ImageDecodeError)>: Unpin, Arc<ImageInner>: Unpin, Rc<dyn Fn(&mut App, bool)>: Unpin, Rc<dyn Fn(&mut App)>: Unpin, NonZero<u32>: Unpin, *const (): Unpin,

§

impl UnsafeUnpin for ImageStreamCompleter
where *const u8 is !null: UnsafeUnpin, PhantomData<ImageStreamListener>: UnsafeUnpin, *const ArcInner<ImageInner> is !null: UnsafeUnpin, PhantomData<ArcInner<ImageInner>>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, bool)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, bool)>>: UnsafeUnpin, PhantomData<Listener>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, *const (): UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>