Drag to Reorder: ReorderableListView Patterns in Flutter
ReorderableListView end to end: the onReorder off-by-one fix, drag handles and drag lifecycle callbacks, proxyDecorator feedback, key rules, Dismissible conflicts, and persisting order.
Published on • November 2, 2026
AI Assistant

Drag-to-reorder is expected behavior in to-do apps, dashboards, and playlists, and Flutter’s ReorderableListView ships the gesture, the drag placeholder, and the reorder callbacks out of the box (docs.flutter.dev).
onReorder and the Off-by-One Fix
onReorder(oldIndex, newIndex) reports indices before the removal, so a row dragged downward lands one slot too far. Correct it before touching the data:
void _onReorder(int oldIndex, int newIndex) {
setState(() {
if (newIndex > oldIndex) newIndex -= 1; // account for the removed row
final row = _rows.removeAt(oldIndex);
_rows.insert(newIndex, row);
});
}
Skip that guard and downward drags land on the wrong slot or past the end of the list. Recent Flutter releases deprecate onReorder in favor of onReorderItem, which hands you newIndex already adjusted — the same method body without the -= 1.
Choosing Drag Handles
With the default buildDefaultDragHandles: true, desktop stacks a drag_handle icon over each row’s trailing edge (a ReorderableDragStartListener), while mobile wraps the whole row in a ReorderableDelayedDragStartListener so a long press starts the drag. Set it to false to own the handle yourself:
ReorderableListView(
buildDefaultDragHandles: false,
scrollDirection: Axis.horizontal, // kanban-style strip
itemBuilder: (context, index) => ListTile(
key: ValueKey(_rows[index].id), // stable and unique
title: Text(_rows[index].title),
leading: ReorderableDragStartListener(
index: index,
child: const Icon(Icons.drag_indicator),
),
),
onReorder: _onReorder,
)
ReorderableDragStartListener starts the drag as soon as the pointer moves — correct for a dedicated handle; ReorderableDelayedDragStartListener waits for a long press, which is what you want when the row itself is tappable.
Feedback and Drag Lifecycle
onReorderStart and onReorderEnd bracket the gesture — pause autoscroll, audio, or timers there — and proxyDecorator lifts the row while it hovers over its neighbors:
ReorderableListView(
onReorderStart: (index) => setState(() => _dragging = true),
onReorderEnd: (index) => setState(() => _dragging = false),
proxyDecorator: (child, index, animation) =>
Material(elevation: 6, color: Colors.transparent, child: child),
itemBuilder: (context, index) => _buildRow(index),
onReorder: _onReorder,
)
Keys, Dismissible, and Persistence
Every row needs a unique, stable Key (ValueKey(item.id)) — the children constructor asserts it outright, and without one the builder variant misidentifies rows mid-drag. Dismissible is the dangerous neighbor: its swipe and the drag listener fight over the same pointer stream, and it demands its own key too, so if you need both actions, put the swipe behind a trailing button instead of nesting it in the reorderable row.
Reordering only mutates memory, so persist the new order yourself:
Future<void> _saveOrder() async {
final prefs = await SharedPreferences.getInstance();
await prefs.setStringList('row_order', _rows.map((r) => r.id).toList());
}
Treat the reorder callback as the single write path — fix the index, move the data, persist — and drag-to-reorder stays correct in every orientation.