maxScrollObstructionExtentBefore method

  1. @override
double maxScrollObstructionExtentBefore(
  1. RenderSliver child
)
override

Returns the total scroll obstruction extent of all slivers in the viewport before child.

This is the extent by which the actual area in which content can scroll is reduced. For example, an app bar that is pinned at the top will reduce the area in which content can actually scroll by the height of the app bar.

Implementation

@override
double maxScrollObstructionExtentBefore(RenderSliver child) {
  assert(
    child.parent == this,
    'The "child" argument must be a child of this RenderViewport.',
  );
  final growthDirection = child.constraints.growthDirection;
  switch (growthDirection) {
    case GrowthDirection.forward:
      var pinnedExtent = 0.0;
      var current = center;
      while (current != child) {
        pinnedExtent += current!.geometry!.maxScrollObstructionExtent;
        current = childAfter(current);
      }
      return pinnedExtent;
    case GrowthDirection.reverse:
      var pinnedExtent = 0.0;
      var current = childBefore(center!);
      while (current != child) {
        pinnedExtent += current!.geometry!.maxScrollObstructionExtent;
        current = childBefore(current);
      }
      return pinnedExtent;
  }
}