drag method Null safety

Future<void> drag (
  1. Finder finder,
  2. Offset offset,
  3. {int? pointer,
  4. int buttons: kPrimaryButton,
  5. double touchSlopX: kDragSlopDefault,
  6. double touchSlopY: kDragSlopDefault}

Attempts to drag the given widget by the given offset, by starting a drag in the middle of the widget.

If the middle of the widget is not exposed, this might send events to another object.

If you want the drag to end with a speed so that the gesture recognition system identifies the gesture as a fling, consider using fling instead.

The operation happens at once. If you want the drag to last for a period of time, consider using timedDrag.

By default, if the x or y component of offset is greater than kDragSlopDefault, the gesture is broken up into two separate moves calls. Changing touchSlopX or touchSlopY will change the minimum amount of movement in the respective axis before the drag will be broken into multiple calls. To always send the drag with just a single call to TestGesture.moveBy, touchSlopX and touchSlopY should be set to 0.

Breaking the drag into multiple moves is necessary for accurate execution of drag update calls with a DragStartBehavior variable set to DragStartBehavior.start. Without such a change, the dragUpdate callback from a drag recognizer will never be invoked.

To force this function to a send a single move event, the touchSlopX and touchSlopY variables should be set to 0. However, generally, these values should be left to their default values.


Future<void> drag(
  Finder finder,
  Offset offset, {
  int? pointer,
  int buttons = kPrimaryButton,
  double touchSlopX = kDragSlopDefault,
  double touchSlopY = kDragSlopDefault,
}) {
  return dragFrom(
    pointer: pointer,
    buttons: buttons,
    touchSlopX: touchSlopX,
    touchSlopY: touchSlopY,