hitTestChildren method
bool
hitTestChildren(
- SliverHitTestResult result, {
- required double mainAxisPosition,
- required double crossAxisPosition,
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.
For a discussion of the semantics of the arguments, see hitTest.
Implementation
@override
bool hitTestChildren(
SliverHitTestResult result, {
required double mainAxisPosition,
required double crossAxisPosition,
}) {
bool tryHitTestPanelChild() {
if (panelChild.geometry!.hitTestExtent > 0) {
return panelChild.hitTest(
result,
mainAxisPosition:
mainAxisPosition - childMainAxisPosition(panelChild),
crossAxisPosition: crossAxisPosition,
);
}
return false;
}
double headerPosition = childMainAxisPosition(headerChild);
if ((mainAxisPosition - headerPosition) <= _headerExtent) {
final didHitHeader = hitTestBoxChild(
BoxHitTestResult.wrap(result),
headerChild,
mainAxisPosition: mainAxisPosition,
crossAxisPosition: crossAxisPosition,
);
if (didHitHeader) {
return didHitHeader;
} else if (_overlapsContent) {
return tryHitTestPanelChild();
} else {
return didHitHeader;
}
} else {
return tryHitTestPanelChild();
}
}