createAnimate method
void
createAnimate()
Implementation
void createAnimate() {
if (widget.controller != null) {
controller = widget.controller!;
} else {
controller = AnimationController(
vsync: this, duration: Duration(milliseconds: widget.duration));
}
animation = Tween(begin: 0.0, end: 1.0).animate(controller)
..addListener(() {
setState(() => null);
});
// 判断是添加监听
if (widget.listener != null) {
animation.addStatusListener(widget.listener);
}
// 判断是否自动播放
if (widget.autoPlay) controller.forward();
}