The Dismissible
widget in Flutter gives you an
onDismissed: (direction) {....}
to tell you the direction it was dragged after it has been dismissed. How can I get the direction (or delta) the widget is currently being dragged?
I tried wrapping it in a GestureDectecor()
which has onHorizontalDragStart:
etc but it seems to stop the Dismissible from working (i.e. you can't drag it)
Flutter Widget - Dismissible() Swiping list items left or right to dismiss them is a pretty common UI pattern. To make it work with Flutter, use the Dismissible widget. Dismissible takes a child, a background, and a key, and it will detect swipe gestures and animate the child, sliding over the background.
Key — Each Dismissible widget should contain a Key to uniquely identify widgets. Background — The background of an item is set to red while performing dismissal action. This is called 'Leave Behind' indicator in Flutter.
I want to disable swiping to the right once there are no data in DataBase. Solution: I just used confirmDismiss in Dismissible widget. confirmDismiss: (direction) { if(data. length > 0 && direction==..) // do stuff else if(...) }
Wrap your Dismissible
widget inside Listener
and use the onPointerMove
callBack.
Listener(
onPointerMove: (PointerMoveEvent event) {
print("Event : $event");
},
child: Dismissible(
...
,
),
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With