isBelowOffsetWidgetInSliver static method

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

Determines whether the offset at the bottom of the target child widget is below the specified offset.

Implementation

static bool isBelowOffsetWidgetInSliver({
  required double scrollViewOffset,
  required Axis scrollDirection,
  required RenderBox targetChild,
  double toNextOverPercent = 1,
}) {
  if (!targetChild.hasSize) return false;
  final parentData = targetChild.parentData;
  if (parentData is! SliverMultiBoxAdaptorParentData) {
    return false;
  }
  final targetFirstChildOffset = parentData.layoutOffset ?? 0;
  final double targetFirstChildSize;
  try {
    // In some cases, getting size may throw an exception.
    targetFirstChildSize = scrollDirection == Axis.vertical
        ? targetChild.size.height
        : targetChild.size.width;
  } catch (_) {
    return false;
  }
  return scrollViewOffset <
      targetFirstChildSize * toNextOverPercent + targetFirstChildOffset;
}