onScaleUpdate method
Implementation
void onScaleUpdate(ScaleUpdateDetails details) {
if (!_isZooming || _controllerReset.isAnimating) {
return;
}
final translationDelta = details.focalPoint - _startFocalPoint;
final translate = Matrix4.translation(
v3.Vector3(translationDelta.dx, translationDelta.dy, 0),
);
final renderBox = context.findRenderObject() as RenderBox;
final focalPoint = renderBox.globalToLocal(
details.focalPoint - translationDelta,
);
var scaleby = details.scale;
if (widget.minScale != null && scaleby < widget.minScale!) {
scaleby = widget.minScale ?? 0;
}
if (widget.maxScale != null && scaleby > widget.maxScale!) {
scaleby = widget.maxScale ?? 0;
}
final dx = (1 - scaleby) * focalPoint.dx;
final dy = (1 - scaleby) * focalPoint.dy;
final scale =
Matrix4(scaleby, 0, 0, 0, 0, scaleby, 0, 0, 0, 0, 1, 0, dx, dy, 0, 1);
_matrix = translate * scale;
if (_transformWidget.currentState != null) {
_transformWidget.currentState!.setMatrix(_matrix);
}
}