Animation<T> class

A value that animates toward whatever you retarget it to.

to moves with a spring (Spring.smooth unless you pass another), so retargeting mid-flight keeps the current velocity; pass a curve for fixed-length easing instead. Reading value in a build rebuilds that widget as the value moves. An Animation you create is yours to dispose; AnimationBuilder manages one for you.

Inheritance

Constructors

Animation(T value, {AnimationType<T>? type, String? debugLabel})
Creates a animation holding value. type is required only for non-built-in T; built-ins (double, int, RgbColor, CellOffset) resolve automatically.

Properties

debugLabel → String?
A label included in diagnostics for this animation.
final
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether at least one listener is registered.
no setterinherited
isMoving → bool
Whether an animation is in flight.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
target → T
The value this animation is currently heading toward.
no setter
value → T
The current interpolated value.
no setter

Methods

addListener(VoidCallback listener) → void
Registers listener to be called when this object changes.
inherited
dispose() → void
Marks this notifier as disposed and drops its listeners. Nulls the slots in place (rather than replacing the backing list) so a dispose called from within a listener leaves any in-progress notify walk reading valid, now-empty slots. After disposal, addListener and notify throw; removeListener remains safe for cleanup.
override
listen(VoidCallback listener) → VoidCallback
Registers listener and returns an idempotent cancellation function.
inherited
loop({required (T, T) between, Duration period = const Duration(milliseconds: 600), Curve curve = Curves.linear, bool mirror = true}) → TickerFuture<T>
Repeats forever between between's two values. With mirror (the default) the direction reverses each cycle (a→b→a→b…); without it, each cycle restarts from the first value (a→b, a→b…). period and curve control one leg of the cycle.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
Publishes a change to every listener registered when the pass began.
inherited
removeListener(VoidCallback listener) → void
Removes a previously-registered listener.
inherited
snap(T value) → void
Jumps to value immediately, cancelling any animation. Use for initial state or hard resets.
stop() → void
Stops the animation where it is, keeping the current value.
to(T target, {Spring? spring, Curve? curve, Duration? duration}) → TickerFuture<T>
Retargets to target. With no curve, uses the spring engine (spring or Spring.smooth) — interruption-friendly, picks up from the current value+velocity. With a curve, uses deterministic easing over duration (defaults to 250ms); interrupting a curve restarts from the current value with zero velocity. Passing duration without curve, or both spring and curve, throws an ArgumentError.
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited