flatten<T> function

List<T> flatten<T>(
  1. List<T> list
)

Flattens array a single level deep.

It returns newObject of flattened array and does not affects the list object called-upon

var list = [2, [1, 3], [4, [1, [2]] ] ];
var newList = flatten(list); // newList = [2, 1, 3, 4, [1, [2] ] ];

Implementation

List<T> flatten<T>(List<T> list) {
  return list.flatten() as List<T>;
}