RepeatedAnimationBuilder<T>.animation constructor

const RepeatedAnimationBuilder<T>.animation({
  1. Key? key,
  2. required T start,
  3. required T end,
  4. required Duration duration,
  5. Curve curve = Curves.linear,
  6. Curve? reverseCurve,
  7. RepeatMode mode = RepeatMode.repeat,
  8. required Widget animationBuilder(
    1. BuildContext context,
    2. Animation<T> animation
    )?,
  9. Widget? child,
  10. T lerp(
    1. T a,
    2. T b,
    3. double t
    )?,
  11. bool play = true,
  12. Duration? reverseDuration,
})

Creates a RepeatedAnimationBuilder with direct Animation access.

This constructor provides the underlying Animation object directly, allowing for advanced animation control and the ability to drive multiple animated properties from a single repeated animation.

Parameters:

  • start (T, required): Starting value of the animation range.
  • end (T, required): Ending value of the animation range.
  • duration (Duration, required): Duration for primary animation direction.
  • curve (Curve, default: Curves.linear): Easing curve for animation.
  • reverseCurve (Curve?, optional): Curve for reverse direction in ping-pong modes.
  • mode (RepeatMode, default: RepeatMode.repeat): Animation repeat behavior.
  • animationBuilder (Function, required): Builds widget from Animation object.
  • child (Widget?, optional): Optional child passed to builder.
  • lerp (Function?, optional): Custom interpolation for complex types.
  • play (bool, default: true): Whether animation should be playing.
  • reverseDuration (Duration?, optional): Duration for reverse direction.

Example:

RepeatedAnimationBuilder<Color>.animation(
  start: Colors.red,
  end: Colors.blue,
  duration: Duration(seconds: 3),
  mode: RepeatMode.pingPong,
  animationBuilder: (context, animation) => Container(
    width: 100,
    height: 100,
    decoration: BoxDecoration(
      color: animation.value,
      borderRadius: BorderRadius.circular(8),
    ),
  ),
);

Implementation

const RepeatedAnimationBuilder.animation({
  super.key,
  required this.start,
  required this.end,
  required this.duration,
  this.curve = Curves.linear,
  this.reverseCurve,
  this.mode = RepeatMode.repeat,
  required this.animationBuilder,
  this.child,
  this.lerp,
  this.play = true,
  this.reverseDuration,
}) : builder = null;