flatten method

Iterable<E> flatten()

Returns a new lazy Iterable of all elements from all collections in this collection.

final nestedList = List([[1, 2, 3], [4, 5, 6]]);
final flattened = nestedList.flatten(); // [1, 2, 3, 4, 5, 6]

Implementation

Iterable<E> flatten() sync* {
  for (final current in this) {
    yield* current;
  }
}