PageView.custom constructor

PageView.custom({
  1. Key? key,
  2. Axis scrollDirection = Axis.horizontal,
  3. bool reverse = false,
  4. PageController? controller,
  5. ScrollPhysics? physics,
  6. bool pageSnapping = true,
  7. ValueChanged<int>? onPageChanged,
  8. required SliverChildDelegate childrenDelegate,
  9. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  10. bool allowImplicitScrolling = false,
  11. ScrollCacheExtent? scrollCacheExtent,
  12. String? restorationId,
  13. Clip clipBehavior = Clip.hardEdge,
  14. HitTestBehavior hitTestBehavior = HitTestBehavior.opaque,
  15. ScrollBehavior? scrollBehavior,
  16. bool padEnds = true,
})

Creates a scrollable list that works page by page with a custom child model.

This example shows a PageView that uses a custom SliverChildBuilderDelegate to support child reordering.
link

To create a local project with this code sample, run:
flutter create --sample=widgets.PageView.PageView.custom.1 mysample

If allowImplicitScrolling is true, the PageView will participate in accessibility scrolling more like a ListView, where implicit scroll actions will move to the next page rather than into the contents of the PageView.

Implementation

PageView.custom({
  super.key,
  this.scrollDirection = Axis.horizontal,
  this.reverse = false,
  this.controller,
  this.physics,
  this.pageSnapping = true,
  this.onPageChanged,
  required this.childrenDelegate,
  this.dragStartBehavior = DragStartBehavior.start,
  this.allowImplicitScrolling = false,
  ScrollCacheExtent? scrollCacheExtent,
  this.restorationId,
  this.clipBehavior = Clip.hardEdge,
  this.hitTestBehavior = HitTestBehavior.opaque,
  this.scrollBehavior,
  this.padEnds = true,
}) : assert(
       scrollCacheExtent == null || (scrollCacheExtent.value > 0.0) == allowImplicitScrolling,
       'scrollCacheExtent and allowImplicitScrolling must be consistent: '
       'scrollCacheExtent must be greater than 0.0 when allowImplicitScrolling is true, '
       'and must be 0.0 when allowImplicitScrolling is false.',
     ),
     scrollCacheExtent =
         scrollCacheExtent ?? ScrollCacheExtent.viewport(allowImplicitScrolling ? 1.0 : 0.0);