buildViewport method

  1. @protected
Widget buildViewport (BuildContext context, ViewportOffset offset, AxisDirection axisDirection, List<Widget> slivers)
@protected

Build the viewport.

Subclasses may override this method to change how the viewport is built. The default implementation uses a ShrinkWrappingViewport if shrinkWrap is true, and a regular Viewport otherwise.

The offset argument is the value obtained from Scrollable.viewportBuilder.

The axisDirection argument is the value obtained from getDirection, which by default uses scrollDirection and reverse.

The slivers argument is the value obtained from buildSlivers.

Implementation

@protected
Widget buildViewport(
  BuildContext context,
  ViewportOffset offset,
  AxisDirection axisDirection,
  List<Widget> slivers,
) {
  if (shrinkWrap) {
    return ShrinkWrappingViewport(
      axisDirection: axisDirection,
      offset: offset,
      slivers: slivers,
    );
  }
  return Viewport(
    axisDirection: axisDirection,
    offset: offset,
    slivers: slivers,
    cacheExtent: cacheExtent,
    center: center,
    anchor: anchor,
  );
}