toString method

  1. @override
String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.

Implementation

@override
String toString() {
  var strBuff = StringBuffer("\n");
  for (var lin = 0; lin < Board.dimension; lin++) {
    for (var col = 0; col < Board.dimension; col++) {
      var value = _values[lin][col] > 0 ? _values[lin][col] : '_';
      strBuff.write("$value ");
      if ((col + 1) % Board.groupSize == 0) {
        strBuff.write(" ");
      }
    }
    strBuff.write("\n");
    if ((lin + 1) % Board.groupSize == 0 && (lin + 1) < Board.dimension) {
      strBuff.write("\n");
    }
  }
  return strBuff.toString();
}