Flutter - How to map mouse position/coordinates when zooming in

Viewed 33

I have a project that uses the "flutter_painter" library to draw on top of an image, the problem is that when I zoom in on the image, the coordinates are still from the original image and not with the zoom applied, I need to map these coordinates to draw under the zoomed image, and when you unzoom it stays in the drawn location.

I use the "onSecondaryTapUp: (details){}" from the "GestureDetector" widget around the "Flutter_Painter" library to get the click position on the image.

1 Answers

try transformationController.toScene(update.localPosition);

_onDragUpdate(BuildContext context, DragUpdateDetails update) {
      RenderBox getBox = context.findRenderObject() as RenderBox;
      var local = getBox.globalToLocal(update.globalPosition);
      final Offset scenePoint = transformationController.toScene(update.localPosition);
      print("Update Point");
      debugPrint("local:  $local");
      debugPrint("scenePoint:  $scenePoint");
     
  }
Related