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?
Work flow of the Flutter AnimationAnimationController(duration: const Duration(seconds: 2), vsync: this); animation = Tween<double>(begin: 0, end: 300). animate(controller); controller. forward(); Add animation based listener, addListener to change the state of the widget.
What is vsync ? Vsync basically keeps the track of screen, so that Flutter does not renders the animation when the screen is not being displayed.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With