hitTestBoxChild method
- @protected
@protected
Utility function for hitTestChildren for use when the children are RenderBox widgets.
This function takes care of converting the position from the sliver coordinate system to the Cartesian coordinate system used by RenderBox.
This function relies on childMainAxisPosition to determine the position of child in question.
Calling this for a child that is not visible is not valid.
Implementation
@protected
bool hitTestBoxChild(HitTestResult result, RenderBox child, { @required double mainAxisPosition, @required double crossAxisPosition }) {
final bool rightWayUp = _getRightWayUp(constraints);
double absolutePosition = mainAxisPosition - childMainAxisPosition(child);
final double absoluteCrossAxisPosition = crossAxisPosition - childCrossAxisPosition(child);
assert(constraints.axis != null);
switch (constraints.axis) {
case Axis.horizontal:
if (!rightWayUp)
absolutePosition = child.size.width - absolutePosition;
return child.hitTest(result, position: Offset(absolutePosition, absoluteCrossAxisPosition));
case Axis.vertical:
if (!rightWayUp)
absolutePosition = child.size.height - absolutePosition;
return child.hitTest(result, position: Offset(absoluteCrossAxisPosition, absolutePosition));
}
return false;
}