Documentation menu
Concepts

Sensors & activation

Sensors translate raw input — pointer, keyboard — into drag intent. The pointer sensor is active by default; activation constraints decide how deliberate a gesture must be before a drag begins.

You'll learn
  • How sensors turn input into drags.
  • How to require a distance or delay before activation.
  • How keyboard dragging fits in.

What sensors do

A DndSensor watches an input source and starts, updates, and ends a drag on the controller. The built-in DndPointerSensor handles mouse, touch, and pen through unified pointer events, so the same code works across devices.

Activation constraints

A DndSensorActivationConstraint delays activation until the gesture clears a threshold, so a tap or click is never mistaken for a drag. Set a small distance for immediate-feeling drags, or a delay for press-and-hold.

activation.dart
DndDraggable(
  id: const DndId('card'),
  constraint: const DndSensorActivationConstraint(distance: 6),
  child: card,
)

A press delay instead of a distance:

activation.dart
DndDraggable(
  id: const DndId('card'),
  constraint: const DndSensorActivationConstraint(
    delay: Duration(milliseconds: 200),
  ),
  child: card,
)

Keyboard

Keyboard dragging is built in: a focused draggable is picked up with space or enter, moved with the arrow keys, and cancelled with escape — no extra wiring. See the accessibility page for the full keyboard model.