defaultHitTestChildren method

bool defaultHitTestChildren (HitTestResult result, { Offset position })

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(HitTestResult 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;
    if (child.hitTest(result, position: position - childParentData.offset))
      return true;
    child = childParentData.previousSibling;
  }
  return false;
}