首页 > 解决方案 > AnimationController animateTo method, always going back to start

问题描述

I am using AnimationController.animateTo method to jump my animation to specific points instantly.

When I pass parameter 'target' with a value of 0.0 to animateTo method, the resulting 'value' property of AnimationController is 0.0. If I pass a parameter 'target' to animateTo method with a value of 0.5, the resulting 'value' property of AnimationController still returns 0.0. I would expect the 'value' property to return 0.5.

void _onPlayButtonPressed() {
    final cpm = ScopedModel.of<CpModel>(context);
    if (cpm.started) {
      cpm.stop();
      _animController.stop();

      var targetProgress = cpm.adjustedProgress;
      _animController.animateTo(targetProgress , duration: Duration(seconds: 0));
    } else {
      _ranOnce = true;
      cpm.start();
      _animController.forward();
    }
  }

标签: flutter

解决方案


推荐阅读