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() {
  DetectionResultColumn? rowIndicatorColumn = _detectionResultColumns[0];
  rowIndicatorColumn ??= _detectionResultColumns[_barcodeColumnCount + 1];
  final formatter = StringBuffer();
  for (int codewordsRow = 0;
      codewordsRow < rowIndicatorColumn!.codewords.length;
      codewordsRow++) {
    formatter.write('CW ${codewordsRow.toString().padLeft(3)}:');
    for (int barcodeColumn = 0;
        barcodeColumn < _barcodeColumnCount + 2;
        barcodeColumn++) {
      if (_detectionResultColumns[barcodeColumn] == null) {
        formatter.write('    |   ');
        continue;
      }
      final codeword =
          _detectionResultColumns[barcodeColumn]!.codewords[codewordsRow];
      if (codeword == null) {
        formatter.write('    |   ');
        continue;
      }
      formatter.write(
        ' ${codeword.rowNumber.toString().padLeft(3)}|${codeword.value.toString().padLeft(3)}',
      );
    }
    formatter.write('\n');
  }
  return formatter.toString();
}