MicroReorderableList class
A reorderable list with a polished lift effect on the dragged item.
Wraps ReorderableListView and decorates the drag proxy with a subtle
scale (about its center) and elevation while it is lifted. Indexes given
to onReorder follow the Flutter SDK convention and are passed through
unchanged: when moving an item down, newIndex is the index before
removal, so callers typically adjust with
if (oldIndex < newIndex) newIndex -= 1;.
Every child must have a Key:
MicroReorderableList(
onReorder: (oldIndex, newIndex) {
setState(() {
if (oldIndex < newIndex) newIndex -= 1;
final item = items.removeAt(oldIndex);
items.insert(newIndex, item);
});
},
children: [
for (final item in items) ListTile(key: ValueKey(item.id), title: Text(item.name)),
],
)
Use MicroReorderableList.builder for large or lazily built lists. Under reduced motion the lifted item keeps its elevation but does not animate its scale.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- MicroReorderableList
Constructors
-
MicroReorderableList({Key? key, required List<
Widget> children, required ReorderCallback onReorder, ValueChanged<int> ? onReorderStart, ValueChanged<int> ? onReorderEnd, EdgeInsets? padding, ScrollController? scrollController, bool shrinkWrap = false, ScrollPhysics? physics, Axis scrollDirection = Axis.vertical, bool buildDefaultDragHandles = true, bool showDragHandle = false, double liftScale = 1.04, double liftElevation = 4.0, ReorderItemProxyDecorator? proxyDecorator}) -
Creates a reorderable list from an explicit list of
children. -
MicroReorderableList.builder({Key? key, required IndexedWidgetBuilder itemBuilder, required int itemCount, required ReorderCallback onReorder, ValueChanged<
int> ? onReorderStart, ValueChanged<int> ? onReorderEnd, EdgeInsets? padding, ScrollController? scrollController, bool shrinkWrap = false, ScrollPhysics? physics, Axis scrollDirection = Axis.vertical, bool buildDefaultDragHandles = true, bool showDragHandle = false, double liftScale = 1.04, double liftElevation = 4.0, ReorderItemProxyDecorator? proxyDecorator}) -
Creates a reorderable list that builds items lazily.
const
Properties
- buildDefaultDragHandles → bool
-
Whether the underlying ReorderableListView adds its own drag
listeners to every item. Ignored (forced to
false) when showDragHandle istrue. Defaults totrue.final -
children
→ List<
Widget> ? -
The items of the list.
nullwhen using MicroReorderableList.builder. Every child must have a key.final - hashCode → int
-
The hash code for this object.
no setterinherited
- itemBuilder → IndexedWidgetBuilder?
-
Lazily builds each item.
nullwhen using the default constructor.final - itemCount → int?
-
Number of items for MicroReorderableList.builder.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- liftElevation → double
-
The elevation of the dragged item while lifted. Defaults to
4.0.final - liftScale → double
-
How much the dragged item scales up while lifted. Defaults to
1.04.final - onReorder → ReorderCallback
-
Called when an item has been dragged to a new position.
final
-
onReorderEnd
→ ValueChanged<
int> ? -
Called with the index of the item when a drag ends.
final
-
onReorderStart
→ ValueChanged<
int> ? -
Called with the index of the item when a drag starts.
final
- padding → EdgeInsets?
-
Padding around the items.
final
- physics → ScrollPhysics?
-
Physics for the list.
final
- proxyDecorator → ReorderItemProxyDecorator?
-
Optional override for the drag proxy decoration. When
nullthe default lift effect (liftScale plus liftElevation) is used.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollController → ScrollController?
-
Optional external scroll controller. The caller keeps ownership.
final
- scrollDirection → Axis
-
The axis along which the list scrolls. Defaults to Axis.vertical.
final
- showDragHandle → bool
-
When
trueeach item shows an explicit drag handle wired with ReorderableDragStartListener, and only the handle starts a drag. Defaults tofalse.final - shrinkWrap → bool
-
Whether the list sizes itself to its children. Defaults to
false.final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited