How to dismiss flutter dismissable widget programmatically?

Viewed 1709

Is it possible to dismiss dismissable programmatically? Not by swipe, but by let's say button click. The only thing that comes in mind is imitating gesture event with a certain velocity, but this sounds horribly wrong.

2 Answers

How about considering an AnimatedList instead.

A scrolling container that animates items when they are inserted or removed. This widget is similar to one created by ListView.builder.

Please try this.

key: Key(UniqueKey().toString()), 

2nd Way

onDismissed: (DismissDirection direction) { dismissViewList(ObjecClass); }

And function is :

dismissViewList(ObjecClass) {
    if (_personList.contains(ObjecClass)) {
    //_personList is list of ObjecClass shown in ListView
      setState(() {
        _personList.remove(ObjecClass);
      });
    }
}
Related