play method
void
play()
Implementation
void play() {
animationController?.dispose();
// get the next playing page
final storyItem = widget.storyItems.firstWhereOrNull((it) => !it!.shown)!;
if (widget.onStoryShow != null) {
widget.onStoryShow!(storyItem);
}
animationController =
AnimationController(duration: storyItem.duration, vsync: this);
animationController!.addStatusListener((status) {
if (status == AnimationStatus.completed) {
storyItem.shown = true;
if (widget.storyItems.last != storyItem) {
beginPlay();
} else {
// done playing
onComplete();
}
}
});
currentAnimation =
Tween(begin: 0.0, end: 1.0).animate(animationController!);
animationController!.forward();
}