remove method
Remove toast
Implementation
void remove(Widget toastWidget) {
final index = items.indexWhere((e) => e.child == toastWidget);
if (index == -1) return;
final toast = items[index];
items.removeAt(index);
listKey.currentState?.removeItem(
index,
(context, animation) => buildItem(animation, toast, true),
duration: toast.duration,
);
Future.delayed(const Duration(seconds: 2), () {
if (items.isEmpty && ToastifyController.instance.has(key!)) {
overlayEntry?.remove();
ToastifyController.instance.remove(key!);
}
});
}