1.動(dòng)畫重復(fù)給定的次數(shù)
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);
}
// 執(zhí)行動(dòng)畫结闸,1秒后超時(shí)取消
TickerFuture tickerFuture = _controller.repeat(reverse: true);
tickerFuture.timeout(Duration(seconds: 1), onTimeout: () {
_controller.stop(canceled: true);
});