memoize method
Returns an iterable whose elements are cached during the first iteration.
During the first time the returned iterable is consumed, its elements are placed into a cache, which is finalized once iteration is complete. On subsequent times the iterable is consumed, the elements from the cache are reused.
Warning: Calling toList
on a memoized iterable without setting
growable to false will undo the memoization on the returned list.
Implementation
Iterable<T> memoize() {
return MemoizedIterable(this);
}