ImplicitlyAnimatedReorderableList<E extends Object> constructor

const ImplicitlyAnimatedReorderableList<E extends Object>({
  1. Key? key,
  2. required List<E> items,
  3. required ImplicitlyAnimatedItemBuilder<Reorderable, E> itemBuilder,
  4. required ItemDiffUtil<E> areItemsTheSame,
  5. RemovedItemBuilder<Reorderable, E>? removeItemBuilder,
  6. UpdatedItemBuilder<Reorderable, E>? updateItemBuilder,
  7. Duration insertDuration = const Duration(milliseconds: 500),
  8. Duration removeDuration = const Duration(milliseconds: 500),
  9. Duration updateDuration = const Duration(milliseconds: 500),
  10. Duration? liftDuration,
  11. Duration? settleDuration,
  12. bool? spawnIsolate,
  13. bool reverse = false,
  14. Axis scrollDirection = Axis.vertical,
  15. ScrollController? controller,
  16. bool? primary,
  17. ScrollPhysics? physics,
  18. bool shrinkWrap = false,
  19. EdgeInsetsGeometry? padding,
  20. Duration reorderDuration = const Duration(milliseconds: 300),
  21. ReorderStartedCallback<E>? onReorderStarted,
  22. required ReorderFinishedCallback<E> onReorderFinished,
  23. Widget? header,
  24. Widget? footer,
})

Creates a Flutter ListView that implicitly animates between the changes of two lists with the support to reorder its items.

The items parameter represents the current items that should be displayed in the list.

The itemBuilder callback is used to build each child as needed. The parent must be a Reorderable widget.

The areItemsTheSame callback is called by the DiffUtil to decide whether two objects represent the same item. For example, if your items have unique ids, this method should check their id equality.

The onReorderFinished callback is called in response to when the dragged item has been released and animated to its final destination. Here you should update the underlying data in your model/bloc/database etc.

The spawnIsolate flag indicates whether to spawn a new isolate on which to calculate the diff between the lists. Usually you wont have to specify this value as the MyersDiff implementation will use its own metrics to decide, whether a new isolate has to be spawned or not for optimal performance.

Implementation

const ImplicitlyAnimatedReorderableList({
  Key? key,
  required List<E> items,
  required ImplicitlyAnimatedItemBuilder<Reorderable, E> itemBuilder,
  required ItemDiffUtil<E> areItemsTheSame,
  RemovedItemBuilder<Reorderable, E>? removeItemBuilder,
  UpdatedItemBuilder<Reorderable, E>? updateItemBuilder,
  Duration insertDuration = const Duration(milliseconds: 500),
  Duration removeDuration = const Duration(milliseconds: 500),
  Duration updateDuration = const Duration(milliseconds: 500),
  Duration? liftDuration,
  Duration? settleDuration,
  bool? spawnIsolate,
  this.reverse = false,
  this.scrollDirection = Axis.vertical,
  this.controller,
  this.primary,
  this.physics,
  this.shrinkWrap = false,
  this.padding,
  this.reorderDuration = const Duration(milliseconds: 300),
  this.onReorderStarted,
  required this.onReorderFinished,
  this.header,
  this.footer,
})  : liftDuration = liftDuration ?? reorderDuration,
      settleDuration = settleDuration ?? liftDuration ?? reorderDuration,
      assert(
        reorderDuration <= const Duration(milliseconds: 1500),
        'The drag duration should not be longer than 1500 milliseconds.',
      ),
      super(
        key: key,
        items: items,
        itemBuilder: itemBuilder,
        areItemsTheSame: areItemsTheSame,
        removeItemBuilder: removeItemBuilder,
        updateItemBuilder: updateItemBuilder,
        insertDuration: insertDuration,
        removeDuration: removeDuration,
        updateDuration: updateDuration,
        spawnIsolate: spawnIsolate,
      );