Flutter Animation 正反向执行动画测试



  •     AnimationController _panelAnimationController;
        _panelAnimationController = new AnimationController(
          vsync: this,
          duration: new Duration(milliseconds: 300),
        );
        Animation<double> animation =
            new Tween(begin: 300.0, end: 0.0).animate(_panelAnimationController);
        animation.addStatusListener((status) {
          if (status == AnimationStatus.completed) {
            //动画执行结束时反向执行动画
            _panelAnimationController.reverse();
          } else if (status == AnimationStatus.dismissed) {
            //动画恢复到初始状态时执行动画(正向)
            _panelAnimationController.forward();
          }
        });
        animation.addListener(() {
          print(animation.value);
        });
        _panelAnimationController.forward();
    

Log in to reply