flattenIterable<E> method
- @Deprecated('Use flatMap instead')
- Iterable<
E> ? selector(- T item
Transforms each element of the iterable into zero or more results of type E
,
and flattens the resulting collections into a single iterable.
Example:
final numbers = [1, 2, 3];
final doubledNumbers = numbers.flatMapIterable((n) => [n, n * 2]);
// doubledNumbers will be [1, 2, 2, 4, 3, 6]
Implementation
@Deprecated('Use flatMap instead')
Iterable<E> flattenIterable<E>(Iterable<E>? Function(T item) selector) sync* {
for (T item in this) {
Iterable<E>? res = selector(item);
if (res != null) yield* res;
}
}