hitTest method

  1. @override
bool hitTest({
  1. Matrix4? transform,
  2. Offset? offset,
  3. Offset? position,
  4. bool checkBounds = true,
})
override

Hit tests this child, returns true if the hit was a success. This should only be called in BoxyDelegate.hitTest.

The transform argument overrides the paint transform of the child, defaults to BoxyChild.transform.

The offset argument specifies the position of this child relative to the boxy, defaults to the offset given to it during layout.

The position argument specifies the position of the hit test relative to the boxy, defaults to the position given to BoxyDelegate.hitTest.

This method returns false if this handle is neither a RenderBox or RenderSliver, since hit testing is dependant on the render protocol.

Implementation

@override
bool hitTest({
  Matrix4? transform,
  Offset? offset,
  Offset? position,
  bool checkBounds = true,
}) {
  if (isIgnored) {
    return false;
  }

  if (offset != null) {
    assert(transform == null,
        'BoxyChild.hitTest only expects either transform or offset to be provided');
    transform = Matrix4.translationValues(offset.dx, offset.dy, 0.0);
  }

  return _parent.hitTestBoxChild(
    child: render,
    position: position ?? _parent.hitPosition!,
    transform: transform ?? this.transform,
    checkBounds: checkBounds,
  );
}