setGridFromBools method
Sets the grid of the Matrix object from a 2D list of boolean values.
This method takes a 2D list of boolean values representing the grid and converts it to the internal Uint8List representation.
Parameters:
input (List<List<bool>>): The 2D list of boolean values representing the grid.
If the input grid is empty or has no rows, the Matrix is cleared.
Implementation
void setGridFromBools(final List<List<bool>> input) {
if (input.isEmpty || input[0].isEmpty) {
clear();
return;
}
cols = input[0].length;
// Create a new Uint8List to store the flattened grid data
_matrix = Uint8List(input.length * cols);
// Copy the input data into the flattened array
for (int y = 0; y < rows; y++) {
for (int x = 0; x < cols; x++) {
cellSet(x, y, input[y][x]);
}
}
}