AValue<T>.double constructor
const
AValue<T>.double ({
- required T value,
- Physics? physics,
- Duration? duration,
- Duration? reverseDuration,
- ValueChanged<
T> ? onValueChanged, - VoidCallback? onEnd,
- required ValueWidgetBuilder<
T> builder, - Widget? child,
- Key? key,
Creates a widget that animates double values.
When using a standard Curve, you must provide a duration. When using a
PhysicsSimulation, the duration can be left null
so the simulation itself
determines the duration.
{@tool snippet} This example shows how to animate a custom value using the default constructor:
AValue<MyCustomType>(
value: _customValue,
normalizeOutputLength: 1,
normalize: (value) => [value.progress],
denormalize: (value) => MyCustomType(progress: value[0]),
physics: Spring.snap,
builder: (context, value, child) => CustomWidget(
value: value,
child: child,
),
)
{@end-tool}
{@tool snippet} This example shows how to animate a color with a spring physics simulation:
AValue.color(
value: _color,
physics: Spring.withDamping(
mass: 1.0,
damping: 0.7,
),
builder: (context, value, child) => Container(
color: value,
child: child,
),
)
{@end-tool}
See also:
- TweenAnimationBuilder, which provides similar functionality but only with curve-based animations
- PhysicsSimulation, the base class for physics-based animations
- Spring, a common physics simulation for natural-feeling animations
- ASize, a specialized version for size animations that animates width and height at layout
Implementation
const AValue.double({
required this.value,
this.physics,
this.duration,
this.reverseDuration,
this.onValueChanged,
this.onEnd,
required this.builder,
this.child,
super.key,
}) : normalize = AValue.normalizeDouble as List<double> Function(T),
denormalize = AValue.denormalizeDouble as T Function(List<double>),
normalizeOutputLength = 1;