CustomViewport constructor

CustomViewport({
  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 offset argument must not be null.

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

Implementation

CustomViewport({
  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,
        'There should be at most one child with the same key as the center child: $center',
      ),
      assert(
        cacheExtentStyle != CacheExtentStyle.viewport || cacheExtent != null,
        'A cacheExtent is required when using cacheExtentStyle.viewport',
      ),
      super(children: slivers);