Skip to main content

AnimationController

Struct AnimationController 

Source
pub struct AnimationController {
    pub lower_bound: f64,
    pub upper_bound: f64,
    pub animation_behavior: AnimationBehavior,
    pub duration: Option<Duration>,
    pub reverse_duration: Option<Duration>,
    /* private fields */
}
Expand description

A controller for an animation.

This class lets you perform tasks such as:

  • Play an animation forward or in reverse, or stop an animation.
  • Set the animation to a specific value.
  • Define the upper and lower bounds of an animation.
  • Create a fling animation effect using a physics simulation.

By default, an AnimationController linearly produces values that range from 0.0 to 1.0, during a given duration.

An AnimationController needs a TickerProvider, Dart’s vsync constructor argument.

Fields§

§lower_bound: f64

The value at which this animation is deemed to be dismissed.

§upper_bound: f64

The value at which this animation is deemed to be completed.

§animation_behavior: AnimationBehavior

The behavior of the controller when accessibility features disable animations.

§duration: Option<Duration>

The length of time this animation should last.

If reverse_duration is specified, then duration is only used when going forward. Otherwise, it specifies the duration going in both directions.

§reverse_duration: Option<Duration>

The length of time this animation should last when going in reverse.

The value of duration is used if this is None.

Implementations§

Source§

impl AnimationController

Source

pub fn to_string(self: Handle<AnimationController>, app: &App) -> String

Dart’s AnimationController.toString, which it inherits from Animation.

Source

pub fn new( app: &mut App, value: Option<f64>, duration: Option<Duration>, reverse_duration: Option<Duration>, lower_bound: f64, upper_bound: f64, animation_behavior: AnimationBehavior, vsync: impl TickerProvider, ) -> Retained<Handle<AnimationController>>

Creates an animation controller.

value is the initial value of the animation; None means lower_bound. vsync is the required TickerProvider. Dart’s defaults: lower_bound 0.0, upper_bound 1.0, animation_behavior Normal; debugLabel is not ported.

Dart’s constructor registers the _tick tear-off with the vended ticker, so creation goes through the App.

Source

pub fn unbounded( app: &mut App, value: f64, duration: Option<Duration>, reverse_duration: Option<Duration>, animation_behavior: AnimationBehavior, vsync: impl TickerProvider, ) -> Retained<Handle<AnimationController>>

Creates an animation controller with no upper or lower bound for its value.

Dart’s defaults: value 0.0, animation_behavior Preserve.

Source

pub fn value(self: Handle<AnimationController>, app: &App) -> f64

The current value of the animation.

Source

pub fn status(self: Handle<AnimationController>, app: &App) -> AnimationStatus

The current status of this animation.

Source

pub fn last_elapsed_duration( self: Handle<AnimationController>, app: &App, ) -> Option<Duration>

The amount of time that has passed between the time the animation started and the most recent tick of the animation.

If the controller is not animating, the last elapsed duration is None.

Source§

impl AnimationController

Source

pub fn view(self: Handle<AnimationController>) -> AnyAnimation<f64>

An AnyAnimation<f64> view of this controller — what to pass where a Dart API wants an Animation<double>. Dart’s view getter returns this; the erased handle is that upcast.

Source

pub fn resync( self: Handle<AnimationController>, app: &mut App, vsync: impl TickerProvider, )

Recreates the Ticker with the new TickerProvider.

Source

pub fn set_value( self: Handle<AnimationController>, app: &mut App, new_value: f64, )

Stops the animation controller and sets the current value of the animation.

Source

pub fn reset(self: Handle<AnimationController>, app: &mut App)

Sets the controller’s value to the lower bound, stopping the animation.

Source

pub fn velocity(self: Handle<AnimationController>, app: &mut App) -> f64

The rate of change of AnimationController::value per second.

Source

pub fn is_animating(self: Handle<AnimationController>, app: &mut App) -> bool

Whether this animation is currently animating in either the forward or reverse direction.

Source

pub fn forward( self: Handle<AnimationController>, app: &mut App, from: Option<f64>, ) -> TickerFuture ⓘ

Starts running this animation forwards (towards the end).

Source

pub fn reverse( self: Handle<AnimationController>, app: &mut App, from: Option<f64>, ) -> TickerFuture ⓘ

Starts running this animation in reverse (towards the beginning).

Source

pub fn toggle( self: Handle<AnimationController>, app: &mut App, from: Option<f64>, ) -> TickerFuture ⓘ

Toggles the direction of this animation.

Source

pub fn animate_to( self: Handle<AnimationController>, app: &mut App, target: f64, duration: Option<Duration>, curve: Rc<dyn Curve>, ) -> TickerFuture ⓘ

Drives the animation from its current value to target.

Source

pub fn animate_back( self: Handle<AnimationController>, app: &mut App, target: f64, duration: Option<Duration>, curve: Rc<dyn Curve>, ) -> TickerFuture ⓘ

Drives the animation from its current value to target, going in reverse.

Source

pub fn repeat( self: Handle<AnimationController>, app: &mut App, min: Option<f64>, max: Option<f64>, reverse: bool, period: Option<Duration>, count: Option<u64>, ) -> TickerFuture ⓘ

Starts running this animation in the forward direction, and restarts the animation when it completes.

Source

pub fn fling( self: Handle<AnimationController>, app: &mut App, velocity: f64, spring_description: Option<SpringDescription>, animation_behavior: Option<AnimationBehavior>, ) -> TickerFuture ⓘ

Drives the animation with a spring and initial velocity.

Source

pub fn animate_with( self: Handle<AnimationController>, app: &mut App, simulation: Box<dyn Simulation>, ) -> TickerFuture ⓘ

Drives the animation according to the given simulation.

Source

pub fn animate_back_with( self: Handle<AnimationController>, app: &mut App, simulation: Box<dyn Simulation>, ) -> TickerFuture ⓘ

Like animate_with, but the status is reported as AnimationStatus::Reverse.

Source

pub fn stop(self: Handle<AnimationController>, app: &mut App, canceled: bool)

Stops running this animation.

Source

pub fn dispose(self: Handle<AnimationController>, app: &mut App)

Release the resources used by this object. The object is no longer usable after this method is called.

Trait Implementations§

Source§

impl Animation<f64> for AnimationController

Source§

fn add_listener( self: Handle<AnimationController>, app: &mut App, listener: Listener, )

Calls the listener every time the value of the animation changes. Read more
Source§

fn remove_listener( self: Handle<AnimationController>, app: &mut App, listener: &Listener, )

Stop calling the listener every time the value of the animation changes. Read more
Source§

fn add_status_listener( self: Handle<AnimationController>, app: &mut App, listener: AnimationStatusListener, )

Calls listener every time the status of the animation changes. Read more
Source§

fn remove_status_listener( self: Handle<AnimationController>, app: &mut App, listener: &AnimationStatusListener, )

Stops calling the listener every time the status of the animation changes. Read more
Source§

fn status(self: Handle<AnimationController>, app: &App) -> AnimationStatus

The current status of this animation.
Source§

fn value(self: Handle<AnimationController>, app: &App) -> f64

The current value of the animation. Read more
Source§

fn to_string_details(self: Handle<AnimationController>, app: &App) -> String

Dart’s Animation.toStringDetails: the status as its arrow.
Source§

fn is_animating(self: Handle<AnimationController>, app: &App) -> bool

Whether this animation is running in either direction.
Source§

fn is_dismissed(self: Handle<Self>, app: &App) -> bool

Whether this animation is stopped at the beginning.
Source§

fn is_completed(self: Handle<Self>, app: &App) -> bool

Whether this animation is stopped at the end.
Source§

fn is_forward_or_completed(self: Handle<Self>, app: &App) -> bool

Whether the current aim of this animation is toward completion.
Source§

fn to_string(self: Handle<Self>, app: &App) -> String

Dart’s Animation.toString: the identity and toStringDetails.
Source§

fn as_animation(self: Handle<Self>) -> AnyAnimation<T>

This animation as the erased AnyAnimation<T> — what to pass where a Dart API takes an Animation<T>. Read more
Source§

impl AnimationEagerListenerMixin for AnimationController

Source§

fn did_register_listener(self: Handle<Self>, _app: &mut App)

This implementation ignores listener registrations.
Source§

fn did_unregister_listener(self: Handle<Self>, _app: &mut App)

This implementation ignores listener registrations.
Source§

fn dispose(self: Handle<Self>, _app: &mut App)

Release the resources used by this object. The object is no longer usable after this method is called. Read more
Source§

impl AnimationLocalListenersMixin for AnimationController

Source§

fn local_listeners_data( self: Handle<AnimationController>, app: &App, ) -> &AnimationLocalListenersData

The mixin’s field on the host.
Source§

fn local_listeners_data_mut( self: Handle<AnimationController>, app: &mut App, ) -> &mut AnimationLocalListenersData

The mixin’s field on the host, mutably.
Source§

fn did_register_listener(self: Handle<AnimationController>, app: &mut App)

Called immediately before a listener is added via add_listener. Read more
Source§

fn did_unregister_listener(self: Handle<AnimationController>, app: &mut App)

Called immediately after a listener is removed via remove_listener. Read more
Source§

fn add_listener(self: Handle<Self>, app: &mut App, listener: Listener)

Calls the listener every time the value of the animation changes. Read more
Source§

fn remove_listener(self: Handle<Self>, app: &mut App, listener: &Listener)

Stop calling the listener every time the value of the animation changes. Read more
Source§

fn clear_listeners(self: Handle<Self>, app: &mut App)

Removes all listeners added with add_listener. Read more
Source§

fn notify_listeners(self: Handle<Self>, app: &mut App)

Calls all the listeners. Read more
Source§

impl AnimationLocalStatusListenersMixin for AnimationController

Source§

fn local_status_listeners_data( self: Handle<AnimationController>, app: &App, ) -> &AnimationLocalStatusListenersData

The mixin’s field on the host.
Source§

fn local_status_listeners_data_mut( self: Handle<AnimationController>, app: &mut App, ) -> &mut AnimationLocalStatusListenersData

The mixin’s field on the host, mutably.
Source§

fn did_register_listener(self: Handle<AnimationController>, app: &mut App)

Called immediately before a status listener is added via add_status_listener. Read more
Source§

fn did_unregister_listener(self: Handle<AnimationController>, app: &mut App)

Called immediately after a status listener is removed via remove_status_listener. Read more
Source§

fn add_status_listener( self: Handle<Self>, app: &mut App, listener: AnimationStatusListener, )

Calls listener every time the status of the animation changes. Read more
Source§

fn remove_status_listener( self: Handle<Self>, app: &mut App, listener: &AnimationStatusListener, )

Stops calling the listener every time the status of the animation changes. Read more
Source§

fn clear_status_listeners(self: Handle<Self>, app: &mut App)

Removes all listeners added with add_status_listener. Read more
Source§

fn notify_status_listeners( self: Handle<Self>, app: &mut App, status: AnimationStatus, )

Calls all the status listeners. Read more
Source§

impl ListenableObject for AnimationController

Source§

fn add_listener( self: Handle<AnimationController>, app: &mut App, listener: Listener, )

Register a closure to be called when the object notifies its listeners.
Source§

fn remove_listener( self: Handle<AnimationController>, app: &mut App, listener: &Listener, )

Remove a previously registered closure from the list of closures that the object notifies.

Auto Trait Implementations§

§

impl !RefUnwindSafe for AnimationController

§

impl !Send for AnimationController

§

impl !Sync for AnimationController

§

impl !UnwindSafe for AnimationController

§

impl Forget for AnimationController

§

impl Freeze for AnimationController
where NonZero<u32>: Freeze, PhantomData<fn() -> Ticker>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn Simulation> is !null: Freeze, PhantomData<RcInner<dyn Simulation>>: Freeze, *const RcInner<Cell<Option<AnimationDirection>>> is !null: Freeze, PhantomData<RcInner<Cell<Option<AnimationDirection>>>>: Freeze, *const u8 is !null: Freeze, PhantomData<usize>: Freeze, PhantomData<Bucket<Listener, usize>>: Freeze, PhantomData<AnimationStatusListener>: Freeze, PhantomData<(AnimationStatusListener, ())>: Freeze,

§

impl Move for AnimationController

§

impl Unpin for AnimationController
where NonZero<u32>: Unpin, Rc<Keep>: Unpin, Rc<dyn Simulation>: Unpin, Rc<Cell<Option<AnimationDirection>>>: Unpin, *const u8 is !null: Unpin, Rc<dyn Fn(&mut App)>: Unpin, *const (): Unpin, Rc<dyn Fn(AnimationStatus, &mut App)>: Unpin,

§

impl UnsafeUnpin for AnimationController
where NonZeroU32Inner: UnsafeUnpin, PhantomData<fn() -> Ticker>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<dyn Simulation> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Simulation>>: UnsafeUnpin, *const RcInner<Cell<Option<AnimationDirection>>> is !null: UnsafeUnpin, PhantomData<RcInner<Cell<Option<AnimationDirection>>>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<usize>: UnsafeUnpin, PhantomData<Bucket<Listener, usize>>: UnsafeUnpin, PhantomData<AnimationStatusListener>: UnsafeUnpin, PhantomData<(AnimationStatusListener, ())>: 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>