ReorderableListView.builder constructor
- Key? key,
- required IndexedWidgetBuilder itemBuilder,
- required int itemCount,
- required ReorderCallback onReorder,
- required ScrollViewProperties properties,
- void onReorderStart(
- int index
- void onReorderEnd(
- int index
- double? itemExtent,
- Widget? prototypeItem,
- ReorderItemProxyDecorator? proxyDecorator,
- bool buildDefaultDragHandles = true,
- EdgeInsets? padding,
- Widget? header,
- ScrollPhysics? physics,
- bool shrinkWrap = false,
- double anchor = 0.0,
- double? cacheExtent,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
- String? restorationId,
- Clip clipBehavior = Clip.hardEdge,
Creates a reorderable list from widget items that are created on demand.
This constructor is appropriate for list views with a large number of children because the builder is called only for those children that are actually visible.
The itemBuilder
callback will be called only with indices greater than
or equal to zero and less than itemCount
.
The itemBuilder
should always return a non-null widget, and actually
create the widget instances when called. Avoid using a builder that
returns a previously-constructed widget; if the list view's children are
created in advance, or all at once when the ReorderableListView itself
is created, it is more efficient to use the ReorderableListView
constructor. Even more efficient, however, is to create the instances
on demand using this constructor's itemBuilder
callback.
This example creates a list using the ReorderableListView.builder constructor. Using the IndexedWidgetBuilder, The list items are built lazily on demand. {@tool dartpad}
** See code in examples/api/lib/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0.dart ** {@end-tool} See also:
- ReorderableListView, which allows you to build a reorderable list with all the items passed into the constructor.
Implementation
ReorderableListView.builder({
Key? key,
required this.itemBuilder,
required this.itemCount,
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(itemCount >= 0),
assert(onReorder != null),
assert(
itemExtent == null || prototypeItem == null,
'You can only pass itemExtent or prototypeItem, not both',
),
assert(buildDefaultDragHandles != null),
super(key: key);