ExpandableReorderableList<K extends Key> constructor
ExpandableReorderableList<K extends Key> ({
- List<
Widget> leads = const <Widget>[], - List<
Widget> tails = const <Widget>[], - List<
ExpandableReorderableListItem< ? children,K> > - OnReorder<
K> ? onReorder, - ScrollController? scrollController,
- VisibilityController<
K> ? visibilityController, - ExpandableReorderableListItemModelController<
K> ? modelsController, - Axis scrollDirection = Axis.vertical,
- Key? key,
An expandable reorderable list.
If onReorder
is specified, it builds a ReorderableListView, if not, it
builds a ListView.
This example, inspired by the ReorderableListView documentation, creates a list using ExpandableReorderableList:
final List<int> _items = List<int>.generate(50, (index) => index);
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
final oddItemColor = colorScheme.primary.withOpacity(0.05);
final evenItemColor = colorScheme.primary.withOpacity(0.15);
return ExpandableReorderableList<ValueKey<int>>(
onReorder: (onReorderParam) {
setState(() {
var newIndex = onReorderParam.newIndex;
if (onReorderParam.oldIndex < onReorderParam.newIndex) {
newIndex -= 1;
}
final int item = _items.removeAt(onReorderParam.oldIndex);
_items.insert(newIndex, item);
});
},
children: _items.map((int item) {
return ExpandableReorderableListItem<ValueKey<int>>(
key: ValueKey<int>(item),
builder: (_, child, model) {
return ReorderableDragStartListener(
index: model.index!,
child: ListTile(
title: Text('Item $item'),
tileColor: item.isOdd ? oddItemColor : evenItemColor,
),
);
},
);
}).toList(),
);
}
Implementation
ExpandableReorderableList({
this.leads = const <Widget>[],
this.tails = const <Widget>[],
List<ExpandableReorderableListItem<K>>? children,
this.onReorder,
this.scrollController,
this.visibilityController,
this.modelsController,
this.scrollDirection = Axis.vertical,
Key? key,
}) : children = children ?? <ExpandableReorderableListItem<K>>[],
super(key: key);