Drag-and-drop · Flutter & Web

Pick up the whole page.

dnd_kit is one drag engine for Flutter and the browser. This page is built with it — every handle, card and chip you can grab below runs on the same runtime.

drag a capability → 0 in stack
Capabilities
Sortable
Keyboard
Modifiers
Auto-scroll
Overlay
Your stack drop here
Showcase

A board you can actually move

A cross-column Kanban built on the supported Jaspr multi-container surface. Drag a card by its handle within a column or across to another — the engine resolves move intent, the board owns the data.

Backlog 7 In progress 2 Review 1 Done 2 moves 0
Backlog7
Axis-locked drag modifier
Press space to pick up, arrow keys to move between cards, space to drop, escape to cancel.
Snap to grid modifier
Press space to pick up, arrow keys to move between cards, space to drop, escape to cancel.
RTL reordering sortable
Press space to pick up, arrow keys to move between cards, space to drop, escape to cancel.
Pointer sensor sensor
Press space to pick up, arrow keys to move between cards, space to drop, escape to cancel.
Collision detection core
Press space to pick up, arrow keys to move between cards, space to drop, escape to cancel.
Restrict to axis modifier
Press space to pick up, arrow keys to move between cards, space to drop, escape to cancel.
Measuring registry core
Press space to pick up, arrow keys to move between cards, space to drop, escape to cancel.
In progress2
Drag overlay portal overlay
Press space to pick up, arrow keys to move between cards, space to drop, escape to cancel.
Keyboard sensor a11y
Press space to pick up, arrow keys to move between cards, space to drop, escape to cancel.
Review1
Edge auto-scroll scroll
Press space to pick up, arrow keys to move between cards, space to drop, escape to cancel.
Done2
Shared engine core
Press space to pick up, arrow keys to move between cards, space to drop, escape to cancel.
SSR hydration jaspr
Press space to pick up, arrow keys to move between cards, space to drop, escape to cancel.
Code

Drag and drop in three steps

Wrap an area in a DndScope, mark a draggable and a drop target, then react when they meet. You own the data; dnd_kit reports the move — the same API on Flutter and the web.

main.dart
import 'package:dnd_kit_flutter/dnd_kit_flutter.dart';
import 'package:flutter/widgets.dart';

// 1. Wrap the area in a DndScope.
DndScope(
  child: Column(
    children: [
      // 2. Make anything draggable.
      DndDraggable(
        id: const DndId('card'),
        onDragEnd: (event) {
          // 3. React when it lands on a target.
          if (event.overId == const DndId('inbox')) {
            moveCardToInbox();
          }
        },
        child: const Text('Drag me'),
      ),

      // ...and anything a drop target.
      DndDroppable(
        id: const DndId('inbox'),
        child: const Text('Inbox'),
      ),
    ],
  ),
)
Capabilities

Everything you need to drag

Six things the library ships. Grab any card by its handle and reorder the grid — this section runs on the sortable preset.

One drag engine

A single framework-neutral runtime powers both Flutter and the web. Collision, modifiers and sortable math are computed identically on every adapter.

Keyboard & a11y

Every draggable is operable from the keyboard with a live region announcing pick up, move and drop — accessibility is built in, not bolted on.

Modifiers

Constrain movement to an axis, snap to a grid or clamp to a boundary by composing pure modifier functions on the active transform.

Auto-scroll

Drag past the edge of a scrollable region and it scrolls to follow, with velocity driven by the same DOM-free math the engine ships.

SSR-safe

Pointer-events based, no document listeners and no dart:js_interop at import time — components pre-render on the server and hydrate cleanly.

Sortable presets

Drop in SortableScope + SortableItem for vertical, horizontal and grid reordering, or build your own on the generic draggable layer.

Playground

Try it yourself

Drag the tokens from the pool into any bucket. Pure generic droppables with live collision feedback.

pool · drag into a bucket
1
2
3
4
5
6
Bucket A0
Bucket B0
Bucket C0
active over state idle