flatten method

List flatten()

Flattens the matrix into a single row.

Returns a new Row containing all elements of the matrix.

Example:

var matrix = Matrix([[1, 2], [3, 4], [5, 6]]);
var flattenedMatrix = matrix.flatten();
print(flattenedMatrix);
// Output: 1  2  3  4  5  6

Implementation

List<dynamic> flatten() {
  //List<dynamic> list = rowIterable.expand((x) => x).toList();
  List<dynamic> newData = [
    for (int i = 0; i < rowCount; i++)
      for (int j = 0; j < columnCount; j++) this[i][j]
  ];
  return newData;
}