isDisplayingChildInSliver static method

bool isDisplayingChildInSliver({
  1. required RenderBox? targetChild,
  2. required double showingChildrenMaxOffset,
  3. required double scrollViewOffset,
  4. required Axis scrollDirection,
  5. double toNextOverPercent = 1,
})

Determines whether the target child widget is being displayed

Implementation

static bool isDisplayingChildInSliver({
  required RenderBox? targetChild,
  required double showingChildrenMaxOffset,
  required double scrollViewOffset,
  required Axis scrollDirection,
  double toNextOverPercent = 1,
}) {
  if (targetChild == null) {
    return false;
  }
  if (!isBelowOffsetWidgetInSliver(
    scrollViewOffset: scrollViewOffset,
    scrollDirection: scrollDirection,
    targetChild: targetChild,
    toNextOverPercent: toNextOverPercent,
  )) {
    return false;
  }
  final parentData = targetChild.parentData;
  if (parentData is! SliverMultiBoxAdaptorParentData) {
    return false;
  }
  final targetChildLayoutOffset = parentData.layoutOffset ?? 0;
  return targetChildLayoutOffset < showingChildrenMaxOffset;
}