confirmPoint method

int? confirmPoint(
  1. double x,
  2. double y,
  3. PolygonBean polygon
)

Thi way make sure which point you click, return point index

Implementation

int? confirmPoint(double x, double y, PolygonBean polygon) {
  try {
    for (int i = 0; i < polygon.polygonPoint.length; i++) {
      if ((polygon.polygonPoint[i].X + polygon.pointsSize! + 15 >= x &&
          x >= polygon.polygonPoint[i].X - polygon.pointsSize! - 15) &&
          (polygon.polygonPoint[i].Y + polygon.pointsSize! + 15 >= y &&
              y >= polygon.polygonPoint[i].Y - polygon.pointsSize! - 15)) {
        return i;
      }
    }
  } catch(e) {
    debugPrint(e as String?);
  }
  return null;
}