letsar / flutter_slidable

A Flutter implementation of slidable list item with directional slide actions.
MIT License
2.73k stars 591 forks source link

Is there a way to close a slidable when tapping anywhere of the screen? #420

Open xu830 opened 1 year ago

xu830 commented 1 year ago

I've put my slidable in a widget, and I wrap the screen containing those slidable with a gesture detector. Is there a way to close a slidable when I tap anywhere on the screen? Is there anything like a controller or a focus node?

I'm using v 2.0.0.

binhdi0111 commented 9 months ago

@letsar Do you have any solution for this problem?

letsar commented 9 months ago

Hi, you can get a SlidableController, allowing you to close it, from a child of a Slidable. If you want to be able to close it by tapping anywhere on the screen, you will have to create you own machinery with a Listener above the whole screen for example. Then it's up to you to find a way to make the SlidableController available for the widget hosting the Listener.