How to get x axis and y axis values of particular image part in flutter

488 Views Asked by At

Am new to flutter and i need to get x axis y axis value of particular place of the image.i have put the image in container and i need to mark one corner of the container image position as (0,0) when I click the any part or place of the image I need to get x axis and y axis value of the clicked position. I don't know how to do it. Please any one help me to do that. Thanks in advance

1

There are 1 best solutions below

0
On BEST ANSWER

Use GestureDetector to track mouse position.

// variables (or states based on your needs) to store positions
double x = 0.0;
double y = 0.0;

// a function to update mouse pointer position (location)
void updatePosition(TapDownDetails details) {
    setState(() {
      x = details.globalPosition.dx;
      y = details.globalPosition.dy;
    });
  }

// image widget
GestureDetector(
   onTapDown: updatePosition,
   child: Image.asset(yourImagePathHere)), <-- change it to your image path
),