addIfNotContains method

void addIfNotContains(
  1. T element
)

Adds an element to the list if it does not already contain it.

Implementation

void addIfNotContains(T element) {
  if (!contains(element)) {
    add(element);
  }
}