hitTest method

  1. @override
bool hitTest(
  1. Rect rect,
  2. Offset position, {
  3. TextDirection? textDirection,
})
override

Tests whether the outer boundary of this border contains position.

The position must be in the same coordinate space as rect. The default implementation checks position against the path returned by getOuterPath.

The textDirection argument must be provided and non-null if the border has a text direction dependency. It may be null if the border will not need the text direction to describe its geometry.

See also:

Implementation

@override
bool hitTest(Rect rect, Offset position, {TextDirection? textDirection}) {
  final BorderRadius resolvedBorderRadius = borderRadius.resolve(textDirection);
  if (resolvedBorderRadius == BorderRadius.zero) {
    return rect.contains(position);
  }
  return resolvedBorderRadius.toRSuperellipse(rect).contains(position);
}