addOrUpdate method

void addOrUpdate(
  1. T item
)

add an item to a list, or update item if it already exists

Implementation

void addOrUpdate(T item) {
  final index = indexOf(item);
  if (index != -1) {
    this[index] = item;
  } else {
    add(item);
  }
}