flattenDeep<T> function

Iterable<T> flattenDeep<T>(
  1. Iterable<Object?> list
)

Recursively flattens all nested Iterables into a single Iterable sequence.

Implementation

Iterable<T> flattenDeep<T>(Iterable<Object?> list) sync* {
  for (var element in list) {
    if (element is! Iterable) {
      yield element as T;
    } else {
      yield* flattenDeep(element);
    }
  }
}