dnd_kit_flutter 0.4.0-dev.0 copy "dnd_kit_flutter: ^0.4.0-dev.0" to clipboard
dnd_kit_flutter: ^0.4.0-dev.0 copied to clipboard

Flutter drag-and-drop toolkit with core widgets, sensors, measuring, overlays, and sortable presets.

example/example.md

dnd_kit_flutter Example #

This package-local example gives pub.dev a compact, illustrative sample. Full runnable Flutter apps live in the repository-level examples/ directory.

import 'package:dnd_kit_flutter/dnd_kit_flutter.dart';
import 'package:flutter/material.dart';

class TaskDropZone extends StatelessWidget {
  const TaskDropZone({super.key});

  @override
  Widget build(BuildContext context) {
    return DndScope(
      child: Stack(
        children: [
          DndDroppable(
            id: const DndId('done'),
            builder: (context, details, child) {
              return DecoratedBox(
                decoration: BoxDecoration(
                  border: Border.all(
                    color: details.isOver ? Colors.blue : Colors.grey,
                  ),
                ),
                child: child,
              );
            },
            child: const SizedBox(
              width: 240,
              height: 160,
              child: Center(child: Text('Drop here')),
            ),
          ),
          DndDraggable(
            id: const DndId('task-1'),
            onDragEnd: (event) {
              if (event.overId == const DndId('done')) {
                // Update application-owned task state here.
              }
            },
            child: const Card(
              child: ListTile(title: Text('Task 1')),
            ),
          ),
          DndDragOverlay(
            builder: (context, details) {
              return const Card(
                child: ListTile(title: Text('Task 1')),
              );
            },
          ),
        ],
      ),
    );
  }
}

More complete examples:

4
likes
0
points
626
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter drag-and-drop toolkit with core widgets, sensors, measuring, overlays, and sortable presets.

Homepage
Repository (GitHub)
View/report issues

Topics

#drag-and-drop #dnd #flutter #sortable

License

unknown (license)

Dependencies

dnd_kit, flutter, meta

More

Packages that depend on dnd_kit_flutter