flatMap<E> method

Iterable<E> flatMap<E>(
  1. Iterable<E> selector(
    1. T item
    )
)

Flattens lists of items into a single iterable.

This function allows you to extract an iterable of elements from each item in the original iterable, then flattens the result.

Example:

List<User> addons = [...];
List<Card> cards = addons.flatMap((e) => e.card).toList();

Implementation

Iterable<E> flatMap<E>(Iterable<E> Function(T item) selector) sync* {
  for (final item in this) {
    yield* selector(item);
  }
}