onReorder property

  1. @Deprecated('Use the onReorderItem callback instead. ' 'The onReorderItem callback adjusts the newIndex parameter for a removed item at the oldIndex. ' 'This feature was deprecated after v3.41.0-0.0.pre.')
ReorderCallback? onReorder
final

A callback used by the list to report that a list item has been dragged to a new location in the list and the application should update the order of the items.

If oldIndex is before newIndex, removing the item at oldIndex from the list will reduce the list's length by one. Implementations will need to account for this when inserting before newIndex.

This callback has been deprecated in favor of onReorderItem, which simplifies the reordering logic by automatically handling index adjustments. To migrate, remove the manual adjustment of newIndex when items are moved downward in the list.

For example:

onReorder: (int oldIndex, int newIndex) {
  if (newIndex > oldIndex) {
    newIndex -= 1;
  }

  // Handle reordering...
}

becomes

onReorderItem: (int oldIndex, int newIndex) {
  // Handle reordering...
}

Implementation

@Deprecated(
  'Use the onReorderItem callback instead. '
  'The onReorderItem callback adjusts the newIndex parameter for a removed item at the oldIndex. '
  'This feature was deprecated after v3.41.0-0.0.pre.',
)
final ReorderCallback? onReorder;