Draggable Widget in Flutter

Updated 30 September 2022

Save

Here we are going to explore the Draggable widget in Flutter.

Introduction

A widget that can be dragged from to a drag target widget.

Check out the official: Draggable Class

When a draggable widget recognizes the start of a drag gesture, it displays a feedback widget that tracks the user’s finger across the screen. If the user lifts their finger while on top of a DragTarget, that target is given the opportunity to accept the data carried by the draggable.

The ignoringFeedbackPointer defaults to true, which means that the feedback widget ignores the pointer during hit testing. Similarly, ignoringFeedbackSemantics defaults to true, and the feedback also ignores semantics when building the semantics tree.

On multitouch devices, multiple drags can occur simultaneously because there can be multiple pointers in contact with the device at once. To limit the number of simultaneous drags, use the maxSimultaneousDrags property. The default is to allow an unlimited number of simultaneous drags.

This widget displays child when zero drags are under way. If childWhenDragging is non-null, this widget instead displays childWhenDragging when one or more drags are underway. Otherwise, this widget always displays child.

Implementation

Create a DraggableWidget class:

Flutter Draggable Demo App:

Thanks for reading.

Happy Coding 🙂

For more Flutter tutorials visit Mobikul Blogs.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home