IterableExtensions<T> extension
Extension methods on Iterable providing collection operations commonly found in other languages but absent from the Dart SDK.
final items = [1, 2, 3, 4, 5];
print(items.chunked(2)); // [[1, 2], [3, 4], [5]]
print(items.windowed(3)); // [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
print(items.intersperse(0)); // [1, 0, 2, 0, 3, 0, 4, 0, 5]
- on
-
- Iterable<
T>
- Iterable<
Methods
-
associate<
K, V> (MapEntry< K, V> transform(T)) → Map<K, V> -
Available on Iterable<
Associates each element of this iterable into a Map by applyingT> , provided by the IterableExtensions extensiontransformto produce a MapEntry. -
chunked(
int size) → Iterable< List< T> > -
Available on Iterable<
Splits this iterable into chunks ofT> , provided by the IterableExtensions extensionsize. -
distinctBy<
K> (K key(T)) → Iterable< T> -
Available on Iterable<
Returns a new iterable containing only elements that are distinct by the value returned byT> , provided by the IterableExtensions extensionkey. -
firstWhereOrNull(
bool test(T)) → T? -
Available on Iterable<
Returns the first element that satisfiesT> , provided by the IterableExtensions extensiontest, ornullif none does. -
intersperse(
T separator) → Iterable< T> -
Available on Iterable<
Returns an iterable withT> , provided by the IterableExtensions extensionseparatorinserted between each pair of consecutive elements. -
partition(
bool test(T)) → (List< T> , List<T> ) -
Available on Iterable<
Partitions this iterable into two lists: elements that satisfyT> , provided by the IterableExtensions extensiontestand those that do not. -
singleWhereOrNull(
bool test(T)) → T? -
Available on Iterable<
Returns the single element that satisfiesT> , provided by the IterableExtensions extensiontest, ornullif none does. -
windowed(
int size) → Iterable< List< T> > -
Available on Iterable<
Returns a sliding window view ofT> , provided by the IterableExtensions extensionsizeover this iterable. -
zip(
Iterable other) → Iterable< List> -
Available on Iterable<
Zips this iterable withT> , provided by the IterableExtensions extensionotherinto an iterable of Lists of length 2.