AnimatedValueBuilder<T> constructor

const AnimatedValueBuilder<T>({
  1. Key? key,
  2. T? initialValue,
  3. required T value,
  4. required Duration duration,
  5. required AnimatedChildBuilder<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
    )?,
  9. Widget? child,
})

Creates an AnimatedValueBuilder with value-based animation.

This is the standard constructor that animates between values using a simple builder callback. The builder receives the current interpolated value and can construct the appropriate widget tree.

Parameters:

  • initialValue (T?, optional): Starting value for animation. If null, no initial animation occurs.
  • value (T, required): Target value to animate to.
  • duration (Duration, required): Animation duration.
  • builder (AnimatedChildBuilder
  • onEnd (Function?, optional): Called when animation completes.
  • curve (Curve, default: Curves.linear): Animation timing curve.
  • lerp (Function?, optional): Custom interpolation for complex types.
  • child (Widget?, optional): Optional child passed to builder.

Example:

AnimatedValueBuilder<double>(
  initialValue: 0.0,
  value: 1.0,
  duration: Duration(milliseconds: 500),
  curve: Curves.easeInOut,
  builder: (context, opacity, child) => Opacity(
    opacity: opacity,
    child: Text('Hello World'),
  ),
);

Implementation

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