flattenDepth<R> method

Iterable<R?> flattenDepth<R>([
  1. int depth = 1
])

Implementation

Iterable<R?> flattenDepth<R>([int depth = 1]) {
  return expand((element) {
    if (element is Iterable && depth > 0) {
      return element.flattenDepth(depth - 1).cast();
    } else {
      return [element].cast();
    }
  });
}