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 new ViewportOffset.zero or new ViewportOffset.fixed.

Implementation

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