ReorderableListView constructor

ReorderableListView(
  1. {Key? key,
  2. required List<Widget> children,
  3. required ReorderCallback onReorder,
  4. void onReorderStart(
    1. int index
    )?,
  5. void onReorderEnd(
    1. int index
    )?,
  6. double? itemExtent,
  7. ItemExtentBuilder? itemExtentBuilder,
  8. Widget? prototypeItem,
  9. ReorderItemProxyDecorator? proxyDecorator,
  10. bool buildDefaultDragHandles = true,
  11. EdgeInsets? padding,
  12. Widget? header,
  13. Widget? footer,
  14. Axis scrollDirection = Axis.vertical,
  15. bool reverse = false,
  16. ScrollController? scrollController,
  17. bool? primary,
  18. ScrollPhysics? physics,
  19. bool shrinkWrap = false,
  20. double anchor = 0.0,
  21. double? cacheExtent,
  22. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  23. ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  24. String? restorationId,
  25. Clip clipBehavior = Clip.hardEdge,
  26. double? autoScrollerVelocityScalar}
)

Creates a reorderable list from a pre-built list of widgets.

This constructor is appropriate for lists with a small number of children because constructing the List requires doing work for every child that could possibly be displayed in the list view instead of just those children that are actually visible.

See also:

  • ReorderableListView.builder, which allows you to build a reorderable list where the items are built as needed when scrolling the list.

Implementation

ReorderableListView({
  super.key,
  required List<Widget> children,
  required this.onReorder,
  this.onReorderStart,
  this.onReorderEnd,
  this.itemExtent,
  this.itemExtentBuilder,
  this.prototypeItem,
  this.proxyDecorator,
  this.buildDefaultDragHandles = true,
  this.padding,
  this.header,
  this.footer,
  this.scrollDirection = Axis.vertical,
  this.reverse = false,
  this.scrollController,
  this.primary,
  this.physics,
  this.shrinkWrap = false,
  this.anchor = 0.0,
  this.cacheExtent,
  this.dragStartBehavior = DragStartBehavior.start,
  this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  this.restorationId,
  this.clipBehavior = Clip.hardEdge,
  this.autoScrollerVelocityScalar,
}) : assert(
      (itemExtent == null && prototypeItem == null) ||
      (itemExtent == null && itemExtentBuilder == null) ||
      (prototypeItem == null && itemExtentBuilder == null),
      'You can only pass one of itemExtent, prototypeItem and itemExtentBuilder.',
     ),
     assert(
       children.every((Widget w) => w.key != null),
       'All children of this widget must have a key.',
     ),
     itemBuilder = ((BuildContext context, int index) => children[index]),
     itemCount = children.length;