AnimationTimeline.pulse constructor
AnimationTimeline.pulse({
- required AnimationController controller,
- Duration hold = Duration.zero,
- Duration rest = Duration.zero,
- bool repeat = false,
- Object? id,
- String? forwardLabel,
- String? holdLabel,
- String? reverseLabel,
- String? restLabel,
- void onStepStart(
- int index,
- AnimationTimelineStep step,
- TimelineDirection direction
- void onStepComplete(
- int index,
- AnimationTimelineStep step,
- TimelineDirection direction
Builds a common pulse cycle for one controller.
The generated sequence is:
- animate forward
- optional
hold - animate reverse
- optional
rest
This is useful for breathing indicators, spotlight pulses, and repeated emphasis without hand-writing the same four-step sequence each time.
Implementation
factory AnimationTimeline.pulse({
required AnimationController controller,
Duration hold = Duration.zero,
Duration rest = Duration.zero,
bool repeat = false,
Object? id,
String? forwardLabel,
String? holdLabel,
String? reverseLabel,
String? restLabel,
void Function(
int index,
AnimationTimelineStep step,
TimelineDirection direction,
)?
onStepStart,
void Function(
int index,
AnimationTimelineStep step,
TimelineDirection direction,
)?
onStepComplete,
}) {
final steps = <AnimationTimelineStep>[
AnimationTimelineStep.forward(
controller,
label: forwardLabel ?? 'pulse-in',
),
if (hold > Duration.zero)
AnimationTimelineStep.delay(hold, label: holdLabel ?? 'hold'),
AnimationTimelineStep.reverse(
controller,
label: reverseLabel ?? 'pulse-out',
),
if (rest > Duration.zero)
AnimationTimelineStep.delay(rest, label: restLabel ?? 'rest'),
];
return AnimationTimeline(
steps: steps,
repeat: repeat,
id: id,
onStepStart: onStepStart,
onStepComplete: onStepComplete,
);
}