containsPoint method

  1. @override
bool containsPoint(
  1. Offset point,
  2. Size size
)
override

Checks if a point is inside this shape.

Used for hit testing to determine if user interactions (clicks, hovers) are within the node's bounds.

Parameters:

  • point - The point to test (in the node's local coordinate space)
  • size - The size of the node

Returns true if the point is inside the shape, false otherwise.

Implementation

@override
bool containsPoint(Offset point, Size size) {
  final centerX = size.width / 2;
  final centerY = size.height / 2;
  final radiusX = size.width / 2;
  final radiusY = size.height / 2;

  // Use ellipse equation: (x-cx)²/rx² + (y-cy)²/ry² <= 1
  final dx = (point.dx - centerX) / radiusX;
  final dy = (point.dy - centerY) / radiusY;
  return (dx * dx + dy * dy) <= 1.0;
}