animateToOffsetAndScale method
Animate the canvas to a new offset and scale
Implementation
Future<void> animateToOffsetAndScale({
required Offset offset,
required double scale,
Duration? duration,
Curve curve = Curves.easeInOut,
}) async {
final anim = AnimationController(vsync: _ticker!, duration: duration ?? defaultAnimationDuration);
final offsetTween = Tween<Offset>(begin: _gsTopLeftOffset, end: offset);
final scaleTween = Tween<double>(begin: _scale, end: scale);
final offsetAnimation = offsetTween.animate(CurvedAnimation(parent: anim, curve: curve));
final scaleAnimation = scaleTween.animate(CurvedAnimation(parent: anim, curve: curve));
anim.addListener(() {
_gsTopLeftOffset = offsetAnimation.value;
_scale = scaleAnimation.value;
markDirty();
});
await anim.forward();
anim.dispose();
}