hitTest method

bool hitTest(
  1. GPoint localPoint, [
  2. bool useShape = false
])

Determines whether the given localPoint is within the bounds of this Graphics object.

If useShape is set to true, the method will test if the point is within the shapes drawn by this object, rather than just the bounding box of those shapes (false by default).

Returns true if the localPoint is within the bounds of this Graphics object, false otherwise.

Implementation

bool hitTest(GPoint localPoint, [bool useShape = false]) {
  if (useShape) {
    final point = Offset(
      localPoint.x,
      localPoint.y,
    );
    for (var e in _drawingQueue) {
      if (e!.path!.contains(point)) {
        return true;
      }
    }
    return false;
  } else {
//      return getBounds().contains(Offset(x, y));
    return getBounds().contains(
      localPoint.x,
      localPoint.y,
    );
  }
}