ReorderableListView constructor Null safety

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. Widget? prototypeItem,
  8. ReorderItemProxyDecorator? proxyDecorator,
  9. bool buildDefaultDragHandles = true,
  10. EdgeInsets? padding,
  11. Widget? header,
  12. Widget? footer,
  13. Axis scrollDirection = Axis.vertical,
  14. bool reverse = false,
  15. ScrollController? scrollController,
  16. bool? primary,
  17. ScrollPhysics? physics,
  18. bool shrinkWrap = false,
  19. double anchor = 0.0,
  20. double? cacheExtent,
  21. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  22. ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  23. String? restorationId,
  24. Clip clipBehavior = Clip.hardEdge}
)

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.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,
}) : assert(scrollDirection != null),
     assert(onReorder != null),
     assert(children != null),
     assert(
       itemExtent == null || prototypeItem == null,
       'You can only pass itemExtent or prototypeItem, not both',
     ),
     assert(
       children.every((Widget w) => w.key != null),
       'All children of this widget must have a key.',
     ),
     assert(buildDefaultDragHandles != null),
     itemBuilder = ((BuildContext context, int index) => children[index]),
     itemCount = children.length;