I am implementing a notification list and have each item dismissable by swipe.
I would like to add a "Clear All" button that will remove all the notifications one by one in an animation similar to the swipe motion.
Is there a way you can access a dismissable widget to dismiss it programmatically? I could just empty the list and setState, however that wouldn't give me an animation.
My list:
ListView.builder(
itemCount: notifications.length,
itemBuilder: (context, i) {
return Dismissible(
key: Key(notifications[i].hashCode.toString()),
onDismissed: (DismissDirection direction){
onDismissed(notifications[i]);
},
child: Card(
child: ListTile(
leading: Text(DateTime
.now()
.difference(notifications[i].happendAt)
.inMinutes
.toString() +
"m ago"),
subtitle: Text(notifications[i].action),
title: Text(notifications[i].title)),
));
})