Skip to content

Files

Latest commit

1859c2a · Apr 18, 2025

History

History

desktop_drop

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jul 12, 2024
Apr 18, 2025
Apr 18, 2025
Mar 26, 2024
Apr 18, 2025
Aug 25, 2023
Apr 18, 2025
Dec 26, 2023
Apr 18, 2025
Aug 18, 2021
Mar 13, 2022
Jul 1, 2021
Apr 18, 2025

desktop_drop

Pub

A plugin which allows user dragging files to your flutter desktop applications.

Windows
Linux
macOS
Android ✅(preview)
Web

Getting Started

  1. Add desktop_drop to your pubspec.yaml.
  desktop_drop: $latest_version
  1. Then you can use DropTarget to receive file drop events.
class ExampleDragTarget extends StatefulWidget {
  const ExampleDragTarget({Key? key}) : super(key: key);

  @override
  _ExampleDragTargetState createState() => _ExampleDragTargetState();
}

class _ExampleDragTargetState extends State<ExampleDragTarget> {
  final List<XFile> _list = [];

  bool _dragging = false;

  @override
  Widget build(BuildContext context) {
    return DropTarget(
      onDragDone: (detail) {
        setState(() {
          _list.addAll(detail.files);
        });
      },
      onDragEntered: (detail) {
        setState(() {
          _dragging = true;
        });
      },
      onDragExited: (detail) {
        setState(() {
          _dragging = false;
        });
      },
      child: Container(
        height: 200,
        width: 200,
        color: _dragging ? Colors.blue.withOpacity(0.4) : Colors.black26,
        child: _list.isEmpty
            ? const Center(child: Text("Drop here"))
            : Text(_list.join("\n")),
      ),
    );
  }
}

LICENSE

see LICENSE file