List flattenDeep(List array) { return array.expand((element) { if (element is List) { return flattenDeep(element); } return [element]; }).toList(); }