Open MSOB7YY opened 1 year ago
same here
yes they allow you to use the controller to implement your own drag handle, wrap your handle in a gesture detector, pass it the animation controller and implement the methods for dragging events
onVerticalDragStart: (dd) { controller.notifyStartReorder( context, dd.localPosition.dx, dd.localPosition.dy, ); }, onVerticalDragUpdate: (dd) { controller.notifyUpdateReorder( dd.localPosition.dx, dd.localPosition.dy, ); }, onVerticalDragEnd: (dd) { controller.notifyStopReorder(false); }, onVerticalDragCancel: () { controller.notifyStopReorder(true); },
Hi,
You can override the reorderModel, just create your own AutomaticAnimatedListReorderModel
:
class MyReorderModel<T> extends AnimatedListBaseReorderModel {
const MyReorderModel(this.list, {this.onReorder});
final List<T> list;
final Function(List<T>)? onReorder;
@override
bool onReorderStart(int index, double dx, double dy) => true;
@override
Object? onReorderFeedback(int index, int dropIndex, double offset, double dx, double dy) => null;
@override
bool onReorderMove(int index, int dropIndex) => true;
@override
bool onReorderComplete(int index, int dropIndex, Object? slot) {
list.insert(dropIndex, list.removeAt(index));
//=====when the reorder complete, you call reorderCallback=====
onReorder?.call(list);
return true;
}
}
is there any widget wrapper that acts as a listener for drags? just like flutter's ReorderableDragStartListener