ImplicitlyAnimatedReorderableList<E extends Object>.separated constructor

ImplicitlyAnimatedReorderableList<E extends Object>.separated({
  1. Key? key,
  2. required List<E> items,
  3. required AnimatedItemBuilder<Reorderable, E> itemBuilder,
  4. required ItemDiffUtil<E> areItemsTheSame,
  5. required NullableIndexedWidgetBuilder separatorBuilder,
  6. RemovedItemBuilder<Reorderable, E>? removeItemBuilder,
  7. UpdatedItemBuilder<Reorderable, E>? updateItemBuilder,
  8. Duration insertDuration = const Duration(milliseconds: 500),
  9. Duration removeDuration = const Duration(milliseconds: 500),
  10. Duration updateDuration = const Duration(milliseconds: 500),
  11. Duration? liftDuration,
  12. Duration? settleDuration,
  13. bool? spawnIsolate,
  14. bool reverse = false,
  15. Axis scrollDirection = Axis.vertical,
  16. ScrollController? controller,
  17. bool? primary,
  18. ScrollPhysics? physics,
  19. bool shrinkWrap = false,
  20. EdgeInsetsGeometry? padding,
  21. Clip clipBehavior = Clip.hardEdge,
  22. Duration reorderDuration = const Duration(milliseconds: 300),
  23. ReorderStartedCallback<E>? onReorderStarted,
  24. required ReorderFinishedCallback<E> onReorderFinished,
  25. Widget? header,
  26. 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 separatorBuilder is the widget that gets placed between itemBuilder(context, index) and itemBuilder(context, index + 1).

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

ImplicitlyAnimatedReorderableList.separated({
  Key? key,
  required List<E> items,
  required AnimatedItemBuilder<Reorderable, E> itemBuilder,
  required ItemDiffUtil<E> areItemsTheSame,
  required NullableIndexedWidgetBuilder separatorBuilder,
  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.clipBehavior = Clip.hardEdge,
  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,
        delegateBuilder: (builder, itemCount) =>
            SliverChildSeparatedBuilderDelegate(
          itemBuilder: builder,
          separatorBuilder: separatorBuilder,
          itemCount: itemCount,
        ),
        areItemsTheSame: areItemsTheSame,
        removeItemBuilder: removeItemBuilder,
        updateItemBuilder: updateItemBuilder,
        insertDuration: insertDuration,
        removeDuration: removeDuration,
        updateDuration: updateDuration,
        spawnIsolate: spawnIsolate,
      );