flutter - Flutter : AnimationController - 没有按钮来控制它?
问题描述
我用 制作了一个动画AnimationController
,我希望它在用户打开应用程序时启动,当动画结束时,用户无需按任何按钮即可转到另一个页面。
解决方案
在您的子类中使用此代码StatefulWidget
。
AnimationController _controller; // member variable
@override
void initState() {
super.initState();
_controller = AnimationController(vsync: this, duration: Duration(seconds: 1));
// start the animation when this page opens
_controller.forward().then((value) {
// animation is finished, you can now go to any page
Navigator.push(context, MaterialPageRoute(builder: (_) => YourPage())); // changed
});
_controller.addListener(() {
// this is your listener, you can also control lots of things from here
});
}
推荐阅读
- angular - How to get rid of Angular6 typescript error?
- maven - 构建成功,但测试无法使用 Maven 运行
- chart.js - Put tooltip on the middle of two bars
- vue.js - Vue路由器不导航
- sinon - Sinon stub argument return fake callback
- css - How create a sticky Navbar that is changing the color while scrolling? [with Typescript in Angular]
- lighttpd - 阻止对 IP 的请求
- regex - Regex get part from "=" first occurence to left and rest to right
- python - how to take (6+5) as a single input from user in python and display the result
- python - Using recursion and memoization with collatz