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 upperBound and lowerBound values 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. The animation controller generates a new value whenever the device running your app is ready to display a new frame (typically, this rate is around 60 values per second).
An AnimationController needs a TickerProvider, which is configured using the vsync
argument
on the constructor. If you are creating an AnimationController from a State, then you can use
the TickerProviderStateMixin and SingleTickerProviderStateMixin classes to obtain a suitable
TickerProvider. The widget test framework WidgetTester
object can be used as a ticker provider
in the context of tests. In other contexts, you will have to either pass a TickerProvider from
a higher level (e.g. indirectly from a State that mixes in TickerProviderStateMixin), or
create a custom TickerProvider subclass.
- Inheritance
- Object
- Listenable
- Animation<double>
- AnimationController
- Mixes-in
- AnimationEagerListenerMixin
- AnimationLocalListenersMixin
- AnimationLocalStatusListenersMixin
Constructors
- AnimationController({double value, Duration duration, String debugLabel, double lowerBound: 0.0, double upperBound: 1.0, @required TickerProvider vsync })
-
Creates an animation controller.
- AnimationController.unbounded({double value: 0.0, Duration duration, String debugLabel, @required TickerProvider vsync })
-
Creates an animation controller with no upper or lower bound for its value.
Properties
- debugLabel → String
-
A label that is used in the toString output. Intended to aid with identifying animation controller instances in debug output.
read-only - duration → Duration
-
The length of time this animation should last.
read / write - isAnimating → bool
-
Whether this animation is currently animating in either the forward or reverse direction.
read-only - lastElapsedDuration → Duration
-
The amount of time that has passed between the time the animation started and the most recent tick of the animation.
read-only - lowerBound → double
-
The value at which this animation is deemed to be dismissed.
read-only - status → AnimationStatus
-
read-only
- upperBound → double
-
The value at which this animation is deemed to be completed.
read-only - value → double
-
The current value of the animation.
read / write - velocity → double
-
read-only
- view → Animation<double>
-
Returns an
Animated<double>
for this animation controller, so that a pointer to this object can be passed around without allowing users of that pointer to mutate the AnimationController state.read-only - hashCode → int
-
Get a hash code for this object.
read-only, inherited - isCompleted → bool
-
Whether this animation is stopped at the end.
read-only, inherited - isDismissed → bool
-
Whether this animation is stopped at the beginning.
read-only, inherited - runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
animateTo(
double target, { Duration duration, Curve curve: Curves.linear }) → Future<Null> -
Drives the animation from its current value to target.
-
animateWith(
Simulation simulation) → Future<Null> -
Drives the animation according to the given simulation.
-
dispose(
) → void -
Release the resources used by this object. The object is no longer usable after this method is called.
-
fling(
{double velocity: 1.0, Force force }) → Future<Null> -
Flings the timeline with an optional force (defaults to a critically damped spring within lowerBound and upperBound) and initial velocity. If velocity is positive, the animation will complete, otherwise it will dismiss.
-
forward(
{double from }) → Future<Null> -
Starts running this animation forwards (towards the end).
-
repeat(
{double min, double max, Duration period }) → Future<Null> -
Starts running this animation in the forward direction, and restarts the animation when it completes.
-
resync(
TickerProvider vsync) → void -
Recreates the Ticker with the new TickerProvider.
-
reverse(
{double from }) → Future<Null> -
Starts running this animation in reverse (towards the beginning).
-
stop(
) → void -
Stops running this animation.
-
toStringDetails(
) → String -
Provides a string describing the status of this object, but not including information about the object itself.
-
addListener(
VoidCallback listener) → void -
Calls the listener every time the value of the animation changes.
inherited -
addStatusListener(
AnimationStatusListener listener) → void -
Calls listener every time the status of the animation changes.
inherited -
didRegisterListener(
) → void -
inherited
-
didUnregisterListener(
) → void -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
notifyListeners(
) → void -
Calls all the listeners.
inherited -
notifyStatusListeners(
AnimationStatus status) → void -
Calls all the status listeners.
inherited -
removeListener(
VoidCallback listener) → void -
Stop calling the listener every time the value of the animation changes.
inherited -
removeStatusListener(
AnimationStatusListener listener) → void -
Stops calling the listener every time the status of the animation changes.
inherited -
toString(
) → String -
Returns a string representation of this object.
inherited