Skip to content
Romain Rastel edited this page Nov 13, 2021 · 2 revisions

How to prevent my SlidableAction to be closed after it has been tapped?

The CustomSlidableAction and SlidableAction widgets have an autoClose constructor parameter with a default value to true. If you don't want your action to be closed automatically, set the autoClose value to false.

How to prevent my Slidable to close after my list has scrolled?

By default, a Slidable closes when the nearest Scrollable widget starts to scroll. To prevent this, you can pass in false to its closeOnScroll constructor parameter.

How can I dismiss my Slidable?

By default, a Slidable is not dismissible. To be dismissed, you have to set a DismissiblePane to the dismissible constructor parameter of any ActionPane:

Slidable(
  // A key is mandatory when using a dismissible.
  key: ValueKey(item),

  // You can choose how which action panes respond to dismiss.
  startActionPane: ActionPane(

    // A pane can dismiss the Slidable.
    dismissible: DismissiblePane(onDismissed: () {}),
  )
),

How can I prevent to dismiss one side but not the other?

Just set the dismissible to the action pane you want to be dismissed and not to the other.

How to let the user cancel a dismissal?

You can set the confirmDismiss callback of the dismissal to show a dialog letting the user deciding if they want to confirm the action.

How to keep only one Slidable open?

You will have to set the same groupTag value to all the Slidables that share the same group and add a SlidableAutoCloseBehavior above your Slidables.

In the snippet below, the first two Slidables have the same group, so only one of them can be open, while the last Slidable is independent of the others.

SlidableAutoCloseBehavior(
  child: ListView(
    children: [
      Slidable(
        groupTag: '0',
      ),
      Slidable(
        groupTag: '0',
      ),
      Slidable(
        groupTag: '1',
      ),
    ],
  ),
)

How can I open the Slidable programmatically?

You can get a SlidableController inside the child of the Slidable. This controller can be used to open the enclosing Slidable programmatically for example by calling openEndActionPane() or openStartActionPane().