hitTest method
- Rect rect,
- Offset position, {
- 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:
- getOuterPath, which creates the path for the outer edge.
- ShapeDecoration.hitTest, which delegates to this method.
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);
}