bounds property

  1. @override
Rect? get bounds
override

Used to get the bounds of the render object when it is time to update clients about visibility.

A null value means bounds are not available.

Implementation

@override
Rect? get bounds {
  if (geometry == null) {
    return null;
  }

  Size widgetSize;
  Offset widgetOffset;
  switch (applyGrowthDirectionToAxisDirection(
    constraints.axisDirection,
    constraints.growthDirection,
  )) {
    case AxisDirection.down:
      widgetOffset = Offset(0, -constraints.scrollOffset);
      widgetSize = Size(constraints.crossAxisExtent, geometry!.scrollExtent);
      break;
    case AxisDirection.up:
      final startOffset = geometry!.paintExtent +
          constraints.scrollOffset -
          geometry!.scrollExtent;
      widgetOffset = Offset(0, math.min(startOffset, 0));
      widgetSize = Size(constraints.crossAxisExtent, geometry!.scrollExtent);
      break;
    case AxisDirection.right:
      widgetOffset = Offset(-constraints.scrollOffset, 0);
      widgetSize = Size(geometry!.scrollExtent, constraints.crossAxisExtent);
      break;
    case AxisDirection.left:
      final startOffset = geometry!.paintExtent +
          constraints.scrollOffset -
          geometry!.scrollExtent;
      widgetOffset = Offset(math.min(startOffset, 0), 0);
      widgetSize = Size(geometry!.scrollExtent, constraints.crossAxisExtent);
      break;
  }
  return widgetOffset & widgetSize;
}