ReorderableListView constructor

ReorderableListView({
  1. Key? key,
  2. required List<Widget> children,
  3. required ReorderCallback onReorder,
  4. required ScrollViewProperties properties,
  5. void onReorderStart(
    1. int index
    )?,
  6. void onReorderEnd(
    1. int index
    )?,
  7. double? itemExtent,
  8. Widget? prototypeItem,
  9. ReorderItemProxyDecorator? proxyDecorator,
  10. bool buildDefaultDragHandles = true,
  11. EdgeInsets? padding,
  12. Widget? header,
  13. Widget? footer,
  14. ScrollPhysics? physics,
  15. bool shrinkWrap = false,
  16. double anchor = 0.0,
  17. double? cacheExtent,
  18. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  19. ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  20. String? restorationId,
  21. 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({
  Key? key,
  required List<Widget> children,
  required this.onReorder,
  required this.properties,
  this.onReorderStart,
  this.onReorderEnd,
  this.itemExtent,
  this.prototypeItem,
  this.proxyDecorator,
  this.buildDefaultDragHandles = true,
  this.padding,
  this.header,
  this.footer,
  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(properties.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,
      super(key: key);