Viewport constructor

Viewport(
  1. {Key? key,
  2. AxisDirection axisDirection = AxisDirection.down,
  3. AxisDirection? crossAxisDirection,
  4. double anchor = 0.0,
  5. required ViewportOffset offset,
  6. Key? center,
  7. double? cacheExtent,
  8. CacheExtentStyle cacheExtentStyle = CacheExtentStyle.pixel,
  9. Clip clipBehavior = Clip.hardEdge,
  10. List<Widget> slivers = const <Widget>[]}
)

Creates a widget that is bigger on the inside.

The viewport listens to the offset, which means you do not need to rebuild this widget when the offset changes.

The cacheExtent must be specified if the cacheExtentStyle is not CacheExtentStyle.pixel.

Implementation

Viewport({
  super.key,
  this.axisDirection = AxisDirection.down,
  this.crossAxisDirection,
  this.anchor = 0.0,
  required this.offset,
  this.center,
  this.cacheExtent,
  this.cacheExtentStyle = CacheExtentStyle.pixel,
  this.clipBehavior = Clip.hardEdge,
  List<Widget> slivers = const <Widget>[],
}) : assert(center == null || slivers.where((Widget child) => child.key == center).length == 1),
     assert(cacheExtentStyle != CacheExtentStyle.viewport || cacheExtent != null),
     super(children: slivers);