According to the documentation for Path:
Closed sub-paths enclose a (possibly discontiguous) region of the plane based on the current fillType.
As far as I understand this implies that when a Path object is closed it surrounds a two dimensional area.
When the user clicks on a point of the screen I want to calculate the distance between the point that the user clicks and the area that's surrounded by the path. I get the point that the user clicks via GestureDetector/onPanDown but I have trouble figuring out how to calculate the distance to the path (or the area surrounded by the path). All the functions that Path offers seem to return void or bool but no distances.
Imagine for illustration: (red is the Path object when I draw it to the screen and the X is supposed to be where my user clicks; the distance between the two represented by the green line is what I'm interested in)
How do I calculate the distance?
First of all traverse through all points of the path. and for each point find out the distance to clicked position and hold the shortest one.
So to get the points of the path use PathMetrics.
got reference from here