onScaleUpdate method

void onScaleUpdate(
  1. ScaleUpdateDetails details
)

Implementation

void onScaleUpdate(ScaleUpdateDetails details) {
  widget.onScaleStart();
  // Reset transformation matrices.
  translationDeltaMatrix = Matrix4.identity();
  scaleDeltaMatrix = Matrix4.identity();
  rotationDeltaMatrix = Matrix4.identity();

  // Handle translation.
  if (widget.shouldTranslate) {
    Offset translationDelta = translationUpdater.update(details.focalPoint);
    translationDeltaMatrix = _translate(translationDelta);
    matrix = translationDeltaMatrix * matrix;
  }

  final focalPointAlignment = widget.focalPointAlignment;
  final focalPoint = focalPointAlignment == null
      ? details.localFocalPoint
      : focalPointAlignment.alongSize(context.size!);

  // Handle scaling.
  if (widget.shouldScale && details.scale != 1.0) {
    double sc = recordOldScale * details.scale;
    if (sc > widget.minScale && sc < widget.maxScale) {
      recordScale = sc;
      double scaleDelta = scaleUpdater.update(details.scale);
      scaleDeltaMatrix = _scale(scaleDelta, focalPoint);
      matrix = scaleDeltaMatrix * matrix;
    }
  }

  // Handle rotation.
  if (widget.shouldRotate && details.rotation != 0.0) {
    double rotationDelta = rotationUpdater.update(details.rotation);
    rotationDeltaMatrix = _rotate(rotationDelta, focalPoint);
    matrix = rotationDeltaMatrix * matrix;
  }
  // Notify the callback with the updated scale and matrix.
  log.log("storage ${matrix.storage}");
  widget.onUpdate(recordScale, matrix);
}