hitTestChildren method
bool
hitTestChildren(
- SliverHitTestResult result, {
- required double mainAxisPosition,
- required double crossAxisPosition,
override
Performs hit testing for children.
Iterates over the cached children state and checks whether the given main and cross axis positions hit any of the child slivers.
Implementation
@override
bool hitTestChildren(
SliverHitTestResult result, {
required double mainAxisPosition,
required double crossAxisPosition,
}) {
if (_childrenState == null) return false;
double currentXOffset = 0;
for (final childState in _childrenState!) {
// if (child.sliver.geometry?.visible ?? false) {
// Adjust the cross axis position relative to the current child.
final adjustedCrossAxisPosition = crossAxisPosition - currentXOffset;
// Check if the hit falls within the child's area.
if (childState.sliver.hitTest(
result,
mainAxisPosition: mainAxisPosition,
crossAxisPosition: adjustedCrossAxisPosition,
)) {
return true; // Stop once a hit is detected.
}
currentXOffset += childState.size ?? 0;
// }
}
return false;
}