desktop_drop 0.7.0
SDKflutter
Platformandroidwindowslinuxmacosweb
A plugin which allows user dragging files to your flutter desktop applications.
desktop_drop_example
Demonstrates how to use the desktop_drop plugin.
Getting Started
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
Example
class ExampleDragTarget extends StatefulWidget {
const ExampleDragTarget({Key? key}) : super(key: key);
@override
_ExampleDragTargetState createState() => _ExampleDragTargetState();
}
class _ExampleDragTargetState extends State<ExampleDragTarget> {
final List<Uri> _list = [];
bool _dragging = false;
@override
Widget build(BuildContext context) {
return DropTarget(
onDragDone: (urls) {
setState(() {
for (final uri in urls) {
debugPrint("uri: ${uri.toFilePath()} "
"${File(uri.toFilePath()).existsSync()}");
}
_list.addAll(urls);
});
},
onDragEntered: () {
setState(() {
_dragging = true;
});
},
onDragExited: () {
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")),
),
);
}
}