collectAllElementsFrom function

Iterable<Element> collectAllElementsFrom(
  1. Element rootElement, {
  2. required bool skipOffstage,
})

Provides an iterable that efficiently returns all the Elements rooted at the given Element. See CachingIterable for details.

This function must be called again if the tree changes. You cannot call this function once, then reuse the iterable after having changed the state of the tree, because the iterable returned by this function caches the results and only walks the tree once.

The same applies to any iterable obtained indirectly through this one, for example the results of calling where on this iterable are also cached.

Implementation

Iterable<Element> collectAllElementsFrom(
  Element rootElement, {
  required bool skipOffstage,
}) {
  return CachingIterable<Element>(_DepthFirstElementTreeIterator(rootElement, !skipOffstage));
}