RenderViewport constructor Null safety

RenderViewport(
  1. {AxisDirection axisDirection = AxisDirection.down,
  2. required AxisDirection crossAxisDirection,
  3. required ViewportOffset offset,
  4. double anchor = 0.0,
  5. List<RenderSliver>? children,
  6. RenderSliver? center,
  7. double? cacheExtent,
  8. CacheExtentStyle cacheExtentStyle = CacheExtentStyle.pixel,
  9. Clip clipBehavior = Clip.hardEdge}
)

Creates a viewport for RenderSliver objects.

If the center is not specified, then the first child in the children list, if any, is used.

The offset must be specified. For testing purposes, consider passing a ViewportOffset.zero or ViewportOffset.fixed.

Implementation

RenderViewport({
  super.axisDirection,
  required super.crossAxisDirection,
  required super.offset,
  double anchor = 0.0,
  List<RenderSliver>? children,
  RenderSliver? center,
  super.cacheExtent,
  super.cacheExtentStyle,
  super.clipBehavior,
}) : assert(anchor != null),
     assert(anchor >= 0.0 && anchor <= 1.0),
     assert(cacheExtentStyle != CacheExtentStyle.viewport || cacheExtent != null),
     assert(clipBehavior != null),
     _anchor = anchor,
     _center = center {
  addAll(children);
  if (center == null && firstChild != null) {
    _center = firstChild;
  }
}