Matrix.fromFlatListOfBool constructor

Matrix.fromFlatListOfBool(
  1. List<bool> inputList,
  2. int width
)

Creates a Matrix from a flat list of boolean values.

inputList A flat list of boolean values. width The width of the resulting matrix.

Implementation

factory Matrix.fromFlatListOfBool(
  final List<bool> inputList,
  final int width,
) {
  final Matrix matrix = Matrix();
  matrix.rows = inputList.length ~/ width;
  matrix.cols = width;

  for (int y = 0; y < matrix.rows; y++) {
    matrix._data
        .add(inputList.sublist(y * matrix.cols, (y + 1) * matrix.cols));
  }
  return matrix;
}