show method

Shows toast, or queues it while DesignToaster.maxVisible are shown. A toast whose DesignToast.id matches one shown or waiting replaces that one in place.

Implementation

DesignToastHandle show(DesignToast toast) {
  final id = toast.id;
  if (id != null) {
    for (final record in [..._shown, ..._waiting]) {
      if (record.id == id && !record.exiting) {
        setState(() => record.toast = toast);
        if (record.shown) _restartTimer(record);
        return DesignToastHandle._(record);
      }
    }
  }
  final record = _ToastRecord(id ?? _ToastId(_nextId++), toast, this);
  _waiting.add(record);
  _promote();
  return DesignToastHandle._(record);
}