addAnimatableAfterLastOne method
SequenceAnimationBuilder
addAnimatableAfterLastOne({
- required Animatable animatable,
- Duration delay = Duration.zero,
- required Duration duration,
- Curve curve = Curves.linear,
- required Object tag,
Convenient wrapper to add an animatable after the last one is finished
delay
is the delay to when this animation should start after the last one finishes.
For example:
SequenceAnimation sequenceAnimation = new SequenceAnimationBuilder()
.addAnimatable(
animatable: new ColorTween(begin: Colors.red, end: Colors.yellow),
from: const Duration(seconds: 0),
to: const Duration(seconds: 2),
tag: "color",
).addAnimatableAfterLastOne(
animatable: new ColorTween(begin: Colors.red, end: Colors.yellow),
delay: const Duration(seconds: 1),
duration: const Duration(seconds: 1),
tag: "animation",
).animate(controller);
The animation with tag "animation" will start at second 3 and run until second 4.
Implementation
SequenceAnimationBuilder addAnimatableAfterLastOne({
required Animatable animatable,
Duration delay: Duration.zero,
required Duration duration,
Curve curve: Curves.linear,
required Object tag,
}) {
assert(_animations.isNotEmpty, "Can not add animatable after last one if there is no animatable yet");
var start = _animations.last.to;
return addAnimatable(animatable: animatable, from: start + delay, to: start + delay + duration, tag: tag, curve: curve);
}