RepeatedAnimationBuilder<T> constructor

const RepeatedAnimationBuilder<T>({
  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 builder(
    1. BuildContext context,
    2. T value,
    3. Widget? child
    )?,
  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 value-based animation.

This constructor provides a simple builder that receives the current animated value. The animation repeats continuously according to the specified mode and can be paused/resumed with the play parameter.

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.
  • builder (Function, required): Builds widget from animated value.
  • 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<double>(
  start: 0.5,
  end: 1.5,
  duration: Duration(seconds: 1),
  mode: RepeatMode.pingPong,
  curve: Curves.easeInOut,
  builder: (context, scale, child) => Transform.scale(
    scale: scale,
    child: Icon(Icons.heart, color: Colors.red),
  ),
);

Implementation

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