defaultHitTestChildren method

bool defaultHitTestChildren (
  1. BoxHitTestResult result,
  2. {Offset position}
)
inherited

Performs a hit test on each child by walking the child list backwards.

Stops walking once after the first child reports that it contains the given point. Returns whether any children contain the given point.

See also:

  • defaultPaint, which paints the children appropriate for this hit-testing strategy.

Implementation

bool defaultHitTestChildren(BoxHitTestResult result, { Offset position }) {
  // The x, y parameters have the top left of the node's box as the origin.
  ChildType child = lastChild;
  while (child != null) {
    final ParentDataType childParentData = child.parentData as ParentDataType;
    final bool isHit = result.addWithPaintOffset(
      offset: childParentData.offset,
      position: position,
      hitTest: (BoxHitTestResult result, Offset transformed) {
        assert(transformed == position - childParentData.offset);
        return child.hitTest(result, position: transformed);
      },
    );
    if (isHit)
      return true;
    child = childParentData.previousSibling;
  }
  return false;
}