produceResult static method

List<bool> produceResult(
  1. List<List<int>> patterns,
  2. int checkSum
)

Implementation

static List<bool> produceResult(List<List<int>> patterns, int checkSum) {
  // Compute and append checksum
  checkSum %= 103;
  if (checkSum < 0) {
    throw ArgumentError('Unable to compute a valid input checksum');
  }

  patterns.add(Code128Reader.codePatterns[checkSum]);

  // Append stop code
  patterns.add(Code128Reader.codePatterns[_codeStop]);

  // Compute code width
  int codeWidth = 0;
  for (List<int> pattern in patterns) {
    for (int width in pattern) {
      codeWidth += width;
    }
  }

  // Compute result
  final result = List.filled(codeWidth, false);
  int pos = 0;
  for (List<int> pattern in patterns) {
    pos += OneDimensionalCodeWriter.appendPattern(result, pos, pattern, true);
  }

  return result;
}