visibleMainAxisSize property

double get visibleMainAxisSize

The visible size of the child widget in the main axis.

Implementation

double get visibleMainAxisSize {
  if (paintExtent == 0) return 0;
  double _visibleMainAxisSize = mainAxisSize;
  final currentChildLayoutOffset = layoutOffset;
  final scrollOffset = sliver.constraints.scrollOffset;
  final leadingScrollViewOffset = scrollOffset + overlap;
  if (leadingScrollViewOffset > currentChildLayoutOffset) {
    // The child widget is blocked by the leading direction side of viewport.
    _visibleMainAxisSize =
        mainAxisSize - (leadingScrollViewOffset - currentChildLayoutOffset);
  } else if (scrollOffset + paintExtent >
      currentChildLayoutOffset + mainAxisSize) {
    // The child widget is being fully displayed.
    _visibleMainAxisSize = mainAxisSize;
  } else {
    // The child widget is blocked by the trailing direction side of viewport.
    _visibleMainAxisSize =
        scrollOffset + paintExtent - currentChildLayoutOffset;
  }
  _visibleMainAxisSize = _visibleMainAxisSize.clamp(0, mainAxisSize);
  return _visibleMainAxisSize;
}