ListView.custom constructor

const ListView.custom({
  1. Key? key,
  2. Axis scrollDirection = Axis.vertical,
  3. bool reverse = false,
  4. ScrollController? controller,
  5. bool? primary,
  6. ScrollPhysics? physics,
  7. bool shrinkWrap = false,
  8. EdgeInsetsGeometry? padding,
  9. double? itemExtent,
  10. Widget? prototypeItem,
  11. ItemExtentBuilder? itemExtentBuilder,
  12. required SliverChildDelegate childrenDelegate,
  13. double? cacheExtent,
  14. int? semanticChildCount,
  15. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  16. ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  17. String? restorationId,
  18. Clip clipBehavior = Clip.hardEdge,
  19. HitTestBehavior hitTestBehavior = HitTestBehavior.opaque,
})

Creates a scrollable, linear array of widgets with a custom child model.

For example, a custom child model can control the algorithm used to estimate the size of children that are not actually visible.

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

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

Implementation

const ListView.custom({
  super.key,
  super.scrollDirection,
  super.reverse,
  super.controller,
  super.primary,
  super.physics,
  super.shrinkWrap,
  super.padding,
  this.itemExtent,
  this.prototypeItem,
  this.itemExtentBuilder,
  required this.childrenDelegate,
  super.cacheExtent,
  super.semanticChildCount,
  super.dragStartBehavior,
  super.keyboardDismissBehavior,
  super.restorationId,
  super.clipBehavior,
  super.hitTestBehavior,
}) : assert(
       (itemExtent == null && prototypeItem == null) ||
       (itemExtent == null && itemExtentBuilder == null) ||
       (prototypeItem == null && itemExtentBuilder == null),
       'You can only pass one of itemExtent, prototypeItem and itemExtentBuilder.',
     );