desktop_drop 0.4.4 copy "desktop_drop: ^0.4.4" to clipboard
desktop_drop: ^0.4.4 copied to clipboard

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

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

341
likes
130
pub points
98%
popularity

Publisher

verified publishermixin.dev

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

cross_file, flutter, flutter_web_plugins

More

Packages that depend on desktop_drop