RepeatedAnimationBuilder<T>.animation constructor
const
RepeatedAnimationBuilder<T>.animation ({
- Key? key,
- required T start,
- required T end,
- required Duration duration,
- Curve curve = Curves.linear,
- Curve? reverseCurve,
- RepeatMode mode = RepeatMode.repeat,
- required Widget animationBuilder(
- BuildContext context,
- Animation<
T> animation
- Widget? child,
- T lerp(
- T a,
- T b,
- double t
- bool play = true,
- 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;