add method
Add new toast
Implementation
void add(Toast toast) {
// Toast child is duplicate because child is constant
if (items.where((e) => e.child == toast.child).isNotEmpty) {
return;
}
// Toast child is duplicate by id
if (toast.id != null && items.where((e) => e.id == toast.id).isNotEmpty) {
return;
}
items.insert(0, toast);
listKey.currentState!.insertItem(0, duration: toast.duration);
if (toast.lifeTime != null) {
Future.delayed(toast.lifeTime! + toast.duration, () {
remove(toast.child);
});
}
}