centerOnGridOffset method
Center the canvas so that the given grid-space offset is at the center of the viewport.
Implementation
void centerOnGridOffset(
Offset gsOffset, {
Duration? duration,
bool animate = true,
}) {
// if 2x scale you need to adjust lesser
final newGsTopLeft =
gsOffset + (canvasSize * (2 * scale)).bottomRight(Offset.zero);
if (animate) {
animateToOffsetAndScale(
offset: newGsTopLeft,
duration: duration,
scale: _scale,
);
} else {
_stopAnimation();
_gsTopLeftOffset = newGsTopLeft;
markDirty();
}
}