flatten method

List<E> flatten()

Returns a new List of all elements from all lists in this List.

var nestedList = [[1, 2, 3], [4, 5, 6]];
var flattened = nestedList.flatten(); // [1, 2, 3, 4, 5, 6]

This is a specialization of IterableIterableX.flatten() which allows accessing elements by index afterwards

var flat = [['a', 'b'], ['c', 'd']].flatten();
print(flat[2]); // prints "c"

Implementation

List<E> flatten() => [for (var list in this) ...list];