addAll method

void addAll(
  1. Iterable<E> iterable
)

Implementation

void addAll(Iterable<E> iterable) {
  // Add directly to the underlying `List` then check elements there, for
  // performance. Roll back the changes if validation fails.
  var safeList = _safeList;
  var lengthBefore = safeList.length;
  safeList.addAll(iterable);
  if (!_needsNullCheck) return;
  try {
    for (var i = lengthBefore; i != safeList.length; ++i) {
      _checkElement(safeList[i]);
    }
  } catch (_) {
    safeList.removeRange(lengthBefore, safeList.length);
    rethrow;
  }
}