Define a TweenAnimation ?

A TweenAnimation is an animation that transitions between two values over a given duration. In Flutter, you can use a Tween to define a TweenAnimation.

Here’s an example of how you might use a Tween to create a TweenAnimation in Flutter:


// Define a Tween
final tween = Tween<double>(begin: 0, end: 1);

// Use the Tween to create a TweenAnimation
return TweenAnimationBuilder(
  tween: tween,
  duration: const Duration(seconds: 2),
  builder: (context, value, child) {
    return Container(
      width: value * 100,
      height: value * 100,
      child: child,
  child: Text('Hello World'),

In this example, the TweenAnimationBuilder widget is used to build the animation. It takes a Tween as an argument and uses it to interpolate between the begin and end values over the specified duration. The builder function is called on each frame of the animation, and it returns a widget that reflects the current value of the animation. The child widget is passed to the builder function and is displayed inside the animated Container widget.

Leave a Comment