Tween<T extends dynamic> class

A linear interpolation between a beginning and ending value.

Tween is useful if you want to interpolate across a range.

To use a Tween object with an animation, call the Tween object's animate method and pass it the Animation object that you want to modify.

You can chain Tween objects together using the chain method, so that a single Animation object is configured by multiple Tween objects called in succession. This is different than calling the animate method twice, which results in two Animation separate objects, each configured with a single Tween.

Sample code

Suppose _controller is an AnimationController, and we want to create an Animation that is controlled by that controller, and save it in _animation:

Animation<Offset> _animation = new Tween<Offset>(
  begin: const Offset(100.0, 50.0),
  end: const Offset(200.0, 300.0),

That would provide an _animation that, over the lifetime of the _controller's animation, returns a value that depicts a point along the line between the two offsets above. If we used a MaterialPointArcTween instead of a Tween in the code above, the points would follow a pleasing curve instead of a straight line, with no other changes necessary.

Implemented by


Tween({T begin, T end })
Creates a tween. [...]


begin ↔ T
The value this variable has at the beginning of the animation. [...]
read / write
end ↔ T
The value this variable has at the end of the animation. [...]
read / write
hashCode int
The hash code for this object. [...]
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


evaluate(Animation<double> animation) → T
Returns the interpolated value for the current value of the given animation. [...]
lerp(double t) → T
Returns the value this variable has at the given animation clock value. [...]
toString() String
Returns a string representation of this object.
animate(Animation<double> parent) Animation<T>
Returns a new Animation that is driven by the given animation but that takes on values determined by this object.
chain(Animatable<double> parent) Animatable<T>
Returns a new Animatable whose value is determined by first evaluating the given parent and then evaluating this object.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]


operator ==(dynamic other) bool
The equality operator. [...]