- override
Override this method to check whether any children are located at the given position.
Typically children should be hit-tested in reverse paint order so that hit tests at locations where children overlap hit the child that is visually "on top" (i.e., paints later).
Used by hitTest
. If you override hitTest
and do not call this
function, then you don't need to implement this function.
Source
@override bool hitTestChildren(HitTestResult result, { Point position }) { final List<RenderBox> children = getChildrenAsList(); for (int i = _lastPaintOrder.length - 1; i >= 0; --i) { final int childIndex = _lastPaintOrder[i]; if (childIndex >= children.length) continue; final RenderBox child = children[childIndex]; final FlowParentData childParentData = child.parentData; final Matrix4 transform = childParentData._transform; if (transform == null) continue; final Matrix4 inverse = new Matrix4.zero(); final double determinate = inverse.copyInverse(transform); if (determinate == 0.0) { // We cannot invert the transform. That means the child doesn't appear // on screen and cannot be hit. continue; } final Point childPosition = MatrixUtils.transformPoint(inverse, position); if (child.hitTest(result, position: childPosition)) return true; } return false; }