flatten function

List flatten(
  1. List list
)

Flatten a list

List dataTypes = [[1, 2, 3], ['a', 'b', 'c'], [true, false, true]];
flatten(dataTypes)
// Returns [1, 2, 3, 'a', 'b', 'c', true, false, true]

Credit goes to Justin Fagnani

Implementation

List flatten(List list) {
  return list.expand((element) => element).toList();
}