1.动画重复给定的次数
late AnimationController _controller;
late Animation _animation;
@override
void initState() {
// TODO: implement initState
super.initState();
_controller = AnimationController(vsync: this, duration: Duration(milliseconds: 100));
_controller.addListener(() => setState(() {}));
_animation = Tween(begin: 0.0, end: 16.0).animate(_controller);
}
// 执行动画,1秒后超时取消
TickerFuture tickerFuture = _controller.repeat(reverse: true);
tickerFuture.timeout(Duration(seconds: 1), onTimeout: () {
_controller.stop(canceled: true);
});
网友评论