我没有找到正确的来源,在此描述了这些信息。我已经做的是滚动的简单动画。类似于自定义NavigationDrawer
。
void setupAnimation(TickerProvider provider, VoidCallback callback) {
controller = AnimationController(duration: duration, vsync: provider);
tween = Tween(begin: 0.0, end: 0.0);
value = tween.animate(controller)..addListener(callback);
}
void playAnimation(double start, double end, Duration duration) {
tween
..begin = start
..end = end;
controller.duration = duration;
controller
..reset()
..forward();
}
所有值更改都是线性的,即使从Tween
对象的源文档中也可以看出。 因此,我正在寻找一种设置值的插值器的简单方法。搜索信息后,我发现了关于反弹动画的类似内容。接下来是来自该来源的小样本。显然,这很好,但仅适用于0.0到1.0的两倍范围。
var rectAnimation = _createTween(parentContext)
.chain(CurveTween(curve: Curves.ease))
.animate(animation);