Drag outside an app

You might want to implement drag and drop somewhere in your app.

You have a couple potential approaches that you can take. One directly uses Flutter widgets and the other uses a package (super_drag_and_drop), available on pub.dev.

Create draggable widgets within your app

If you want to implement drag and drop within your application, you can use the Draggable widget. For insight into this approach, see the Drag a UI element within an app recipe.

An advantage of using Draggable and and DragTarget is that you can supply Dart code to decide whether to accept a drop.

For more information, check out the Draggable widget of the week video.

Implement drag and drop between apps

If you want to implement drag and drop within your application and also between your application and another (possibly non-Flutter) app, check out the super_drag_and_drop package.

To avoid implementing two styles of drag and drop, one for drags outside of the app and another for dragging inside the app, you can supply local data to the package to perform drags within your app.

Another difference between this approach and using Draggable directly, is that you must tell the package up front what data your app accepts because the platform APIs need a synchronous response, which doesn’t allow an asynchronous response from the framework.

An advantage of using this approach is that it works across desktop, mobile, and web.