flutter - Flutter:AnimationController-无需按钮即可控制吗?

标签 flutter dart flutter-animation

我使用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
  });
}

关于flutter - Flutter:AnimationController-无需按钮即可控制吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60041728/

相关文章:

Flutter 如何让 2-Card Carousel Slide with Indicator?

ios - 错误 : unable to read input file as a property list: The operation couldn’t be completed.(XCBUtil.PropertyListConversionError 错误 1。)

google-maps - 自定义图标方向 anchor Flutter Google map

google-maps - 如何在 Flutter 中更改谷歌地图标记的图标大小?

dart - 没有为类型 '[]=' 定义运算符 'String'

mobile - 滚动时如何隐藏BottomNavigationBar-Flutter

flutter - Flutter 中 PageView 的默认曲线行为是什么?

flutter - 如何在 flutter 中为BottomNavigationBar菜单提供onPress功能?

firebase - 如何从 Flutter 中的 UploadTaskSnapshot 获取完整的 downloadUrl?

dart - 澄清避免_null_checks_in_equality_operators短绒规则