protected override bool hitTestChildren(BoxHitTestResult result, Offset position)
        {
            D.assert(position != null);
            RenderBox child = lastChild;

            while (child != null)
            {
                _SlidingSegmentedControlContainerBoxParentData childParentData =
                    child.parentData as _SlidingSegmentedControlContainerBoxParentData;
                if ((childParentData.offset & child.size).contains(position))
                {
                    Offset center = (Offset.zero & child.size).center;
                    return(result.addWithRawTransform(
                               transform: MatrixUtils.forceToPoint(center),
                               position: center,
                               hitTest: (BoxHitTestResult result1, Offset position1) => {
                        D.assert(position1 == center);
                        return child.hitTest(result1, position: center);
                    }
                               ));
                }
                child = childParentData.previousSibling;
            }
            return(false);
        }
Exemple #2
0
        public override bool hitTest(BoxHitTestResult result, Offset position = null)
        {
            if (base.hitTest(result, position: position))
            {
                return(true);
            }

            Offset center = child.size.center(Offset.zero);

            return(result.addWithRawTransform(
                       transform: MatrixUtils.forceToPoint(center),
                       position: center,
                       hitTest: (BoxHitTestResult boxHitTest, Offset offsetPosition) => {
                D.assert(offsetPosition == center);
                //WARNING: inconsistent with flutter (zxw): I believe that there is a bug here in flutter
                //in flutter, the following line is "return child.hitTest(boxHitTest, position: center); ". This is nonsense since it will always return true regardless of the value of the input parameter: position.
                //we have tested a bit in flutter and found that, since an inputPadding has a Semantics as it parent which shares the same size, the Semantics's hitTest can hide this bug in flutter
                //Therefore this bug only occurs in UIWidgets
                //We are not very clear whether this is the best fix though. Please feel free to optimize it
                return child.hitTest(boxHitTest, position: position);
            }
                       ));
        }