-2

I have integrated zoom image logic on double tap here is full code

 void _handleDoubleTap(Offset tapPosition) {
    if (_isZoomed) {
      _transformationController.value = Matrix4.identity();
      _isZoomed = false;
    } else {
      final RenderBox renderBox = context.findRenderObject() as RenderBox;
      final Size size = renderBox.size;

      double zoomScale = 2.5;
      double x = -(tapPosition.dx * (zoomScale - 1));
      double y = -(tapPosition.dy * (zoomScale - 1));

      // Ensure boundaries
      x = x.clamp(-size.width, 0);
      y = y.clamp(-size.height, 0);

      _transformationController.value =
          Matrix4.identity()
            ..translate(x, y)
            ..scale(zoomScale);

      _isZoomed = true;
    }
  }

where i user Matrix4 params which are deprecated so i need solution for this can anyone help me with this?

1 Answer 1

1

this issue can solve by using translateByVector3, translateByVector4, or translateByDouble depending on your use case.

Since you’re working with 2D translation (x and y only), the correct replacement is translateByVector3.

_transformationController.value = Matrix4.identity()
  ..translateByVector3(Vector3(x, y, 0))
  ..scale(zoomScale);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.