AnimatedValueBuilder<T>.animation constructor

const AnimatedValueBuilder<T>.animation({
  1. Key? key,
  2. T? initialValue,
  3. required T value,
  4. required Duration duration,
  5. required AnimationBuilder<T> builder,
  6. void onEnd(
    1. T value
    )?,
  7. Curve curve = Curves.linear,
  8. T lerp(
    1. T a,
    2. T b,
    3. double t
    )?,
})

Creates an AnimatedValueBuilder with direct Animation access.

This constructor provides the underlying Animation object directly to the builder, allowing for advanced animation control and multiple listeners. Useful when you need access to animation status or want to drive multiple animated properties from a single animation.

Parameters:

  • initialValue (T?, optional): Starting value for animation.
  • value (T, required): Target value to animate to.
  • duration (Duration, required): Animation duration.
  • builder (AnimationBuilder
  • onEnd (Function?, optional): Called when animation completes.
  • curve (Curve, default: Curves.linear): Animation timing curve.
  • lerp (Function?, optional): Custom interpolation function.

Example:

AnimatedValueBuilder<Color>.animation(
  value: Colors.blue,
  duration: Duration(seconds: 1),
  builder: (context, animation) => AnimatedBuilder(
    animation: animation,
    builder: (context, child) => Container(
      color: animation.value,
      child: Text('Color transition'),
    ),
  ),
);

Implementation

const AnimatedValueBuilder.animation({
  super.key,
  this.initialValue,
  required this.value,
  required this.duration,
  required AnimationBuilder<T> builder,
  this.onEnd,
  this.curve = Curves.linear,
  this.lerp,
})  : builder = null,
      animationBuilder = builder,
      child = null,
      rawBuilder = null;