gridToStrings method

List<String> gridToStrings({
  1. String onChar = '#',
  2. String offChar = '.',
})

Converts the matrix to a list of strings.

Each string represents a row in the matrix.

Implementation

List<String> gridToStrings({
  final String onChar = '#',
  final String offChar = '.',
}) {
  final List<String> result = [];

  for (int row = 0; row < rows; row++) {
    String rowString = '';
    for (int col = 0; col < cols; col++) {
      rowString += cellGet(col, row) ? onChar : offChar;
    }

    result.add(rowString);
  }

  return result;
}