insertAll method

void insertAll (Iterable<OverlayEntry> entries, { OverlayEntry below, OverlayEntry above })

Insert all the entries in the given iterable.

If below is non-null, the entries are inserted just below below. If above is non-null, the entries are inserted just above above. Otherwise, the entries are inserted on top.

It is an error to specify both above and below.

Implementation

void insertAll(Iterable<OverlayEntry> entries, { OverlayEntry below, OverlayEntry above }) {
  assert(
    above == null || below == null,
    'Only one of `above` and `below` may be specified.',
  );
  assert(
    above == null || (above._overlay == this && _entries.contains(above)),
    'The provided entry for `above` is not present in the Overlay.',
  );
  assert(
    below == null || (below._overlay == this && _entries.contains(below)),
    'The provided entry for `below` is not present in the Overlay.',
  );
  assert(
    entries.every((OverlayEntry entry) => !_entries.contains(entry)),
    'One or more of the specified entries are already present in the Overlay.'
  );
  assert(
    entries.every((OverlayEntry entry) => entry._overlay == null),
    'One or more of the specified entries are already present in another Overlay.'
  );
  if (entries.isEmpty)
    return;
  for (OverlayEntry entry in entries) {
    assert(entry._overlay == null);
    entry._overlay = this;
  }
  setState(() {
    _entries.insertAll(_insertionIndex(below, above), entries);
  });
}