完成小部件动画后,在Flutter中运行一个函数 [英] After complete the widget animation run a function in Flutter
本文介绍了完成小部件动画后,在Flutter中运行一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Flutter框架中,通过扩展AnimatedWidget类实现了一个简单的动画小部件,该小部件可以改变颜色。完成小部件动画后,如何运行一个函数?
In Flutter framework by extending the AnimatedWidget class is implemented a simple animation widget that changes color. How is it possible after complete the widget animation run a function?
推荐答案
您可以监听 AnimationController
:
You can listen on the status of an AnimationController
:
var _controller = new AnimationController(
0.0,
const Duration(milliseconds: 200),
);
_controller.addStatusListener((status) {
if(status == AnimationStatus.completed) {
// custom code here
}
});
Animation<Offset> _animation = new Tween<Offset>(
begin: const Offset(100.0, 50.0),
end: const Offset(200.0, 300.0),
).animate(_controller);
这篇关于完成小部件动画后,在Flutter中运行一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文