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. @Deprecated('Use scrollCacheExtent instead. ' 'This feature was deprecated after v3.41.0-0.0.pre.') double? cacheExtent,
  8. @Deprecated('Use scrollCacheExtent instead. ' 'This feature was deprecated after v3.41.0-0.0.pre.') CacheExtentStyle cacheExtentStyle = CacheExtentStyle.pixel,
  9. ScrollCacheExtent? scrollCacheExtent,
  10. SliverPaintOrder paintOrder = SliverPaintOrder.firstIsTop,
  11. Clip clipBehavior = Clip.hardEdge,
  12. 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.

Implementation

Viewport({
  super.key,
  this.axisDirection = AxisDirection.down,
  this.crossAxisDirection,
  this.anchor = 0.0,
  required this.offset,
  this.center,
  @Deprecated(
    'Use scrollCacheExtent instead. '
    'This feature was deprecated after v3.41.0-0.0.pre.',
  )
  this.cacheExtent,
  @Deprecated(
    'Use scrollCacheExtent instead. '
    'This feature was deprecated after v3.41.0-0.0.pre.',
  )
  this.cacheExtentStyle = CacheExtentStyle.pixel,
  this.scrollCacheExtent,
  this.paintOrder = SliverPaintOrder.firstIsTop,
  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);