ImplicitlyAnimatedReorderableList<E extends Object> constructor
- Key? key,
- required List<
E> items, - required dynamic 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,
- bool reverse = false,
- Axis scrollDirection = Axis.vertical,
- ScrollController? controller,
- bool? primary,
- ScrollPhysics? physics,
- bool shrinkWrap = false,
- EdgeInsetsGeometry? padding,
- Duration reorderDuration = const Duration(milliseconds: 300),
- ReorderStartedCallback<
E> ? onReorderStarted, - required ReorderFinishedCallback<
E> onReorderFinished, - Widget? header,
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 AnimatedItemBuilder<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,
);