animateTo method
Implementation
void animateTo(String key, double from, double to, Duration duration, Curve curve) {
if (animationMap.containsKey(key)) {
final animation = animationMap[key]!;
animation.tween.begin = from;
animation.tween.end = to;
if (from != to) {
animation.controller.stop();
animation.controller.reset();
animation.controller.forward();
}
return;
}
final controller = AnimationController(vsync: vsync, duration: duration)
..addListener(notifyListeners)
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
animationMap.remove(key)?.controller.dispose();
}
})
..forward();
animationMap[key] = (
controller: controller,
curve: curve,
tween: Tween(begin: from, end: to)
);
}