Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Dismissable dragged amount before it's dismissed - Flutter

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)

like image 926
MSpeed Avatar asked Jan 01 '19 15:01

MSpeed


People also ask

How to use Dismissible in Flutter?

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.

What is key in dismissible flutter?

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.

How do you turn off slidable 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(...) }


1 Answers

Wrap your Dismissible widget inside Listener and use the onPointerMove callBack.

  Listener(
            onPointerMove: (PointerMoveEvent event) {
              print("Event : $event");
            },
            child: Dismissible(
             ...
             ,
            ),
          )
like image 164
diegoveloper Avatar answered Sep 21 '22 19:09

diegoveloper