addAll method

  1. @override
void addAll(
  1. Iterable<E> iterable
)

Appends all objects of iterable to the end of this list.

Extends the length of the list by the number of objects in iterable. Throws an UnsupportedError if this list is fixed-length.

If any of iterable's values are contained in the list, a DuplicateValueError will be thrown if the list is strict, otherwise just the values contained within the list will be ignored.

Implementation

@override
void addAll(Iterable<E> iterable) {
  if (!growable) {
    throw UnsupportedError('Cannot add values to a fixed-length list.');
  }
  final elements = iterable.toList();
  for (var value in iterable) {
    if (_contains(value)) {
      if (strict) {
        throw DuplicateValueError(value);
      } else {
        elements.remove(value);
      }
    }
  }
  this.elements.addAll(elements);
}