add method

  1. @override
void add(
  1. E value
)

Adds value to the end of this list, extending the length by one.

Throws an UnsupportedError if the list is fixed-length.

If value already exists in the list, a DuplicateValueError will be thrown if the list is strict, otherwise the value will just not be added to the list.

Implementation

@override
void add(E value) {
  if (!growable) {
    throw UnsupportedError('Cannot add values to a fixed-length list.');
  }
  if (_contains(value)) {
    if (strict) {
      throw DuplicateValueError(value);
    } else {
      return;
    }
  }
  elements.add(value);
}