flatten<T> function
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>;
}