flatten function Null safety

List flatten(
  1. List array
)

Flattens array a single level deep.

Implementation

List flatten(List array) {
  return array
      .expand((element) => element is List ? element : [element])
      .toList();
}