startItemDrag method
- {@required int index,
- @required PointerDownEvent event,
- @required MultiDragGestureRecognizer recognizer}
Initiate the dragging of the item at index
that was started with
the pointer down event
.
The given recognizer
will be used to recognize and start the drag
item tracking and lead to either an item drag, or a cancelled drag.
Most applications will not use this directly, but will wrap the item (or part of the item, like a drag handle) in either a DraggableDragStartListener or DraggableDelayedDragStartListener which call this method when they detect the gesture that triggers a drag start.
Implementation
void startItemDrag({
@required int index,
@required PointerDownEvent event,
@required MultiDragGestureRecognizer recognizer,
}) {
assert(0 <= index && index < widget.itemCount);
setState(() {
if (_reorderingDrag) {
cancelDrag();
}
if (_items.containsKey(index)) {
_dragItem = _items[index];
_recognizer = recognizer
..onStart = _dragStart
..addPointer(event);
} else {
throw Exception('Attempting to start a drag on a non-visible item');
}
});
}