getBarcodeMetadata method
Implementation
BarcodeMetadata? getBarcodeMetadata() {
final codewords = this.codewords;
final barcodeColumnCount = BarcodeValue();
final barcodeRowCountUpperPart = BarcodeValue();
final barcodeRowCountLowerPart = BarcodeValue();
final barcodeECLevel = BarcodeValue();
for (Codeword? codeword in codewords) {
if (codeword == null) {
continue;
}
codeword.setRowNumberAsRowIndicatorColumn();
final rowIndicatorValue = codeword.value % 30;
int codewordRowNumber = codeword.rowNumber;
if (!isLeft) {
codewordRowNumber += 2;
}
switch (codewordRowNumber % 3) {
case 0:
barcodeRowCountUpperPart.setValue(rowIndicatorValue * 3 + 1);
break;
case 1:
barcodeECLevel.setValue(rowIndicatorValue ~/ 3);
barcodeRowCountLowerPart.setValue(rowIndicatorValue % 3);
break;
case 2:
barcodeColumnCount.setValue(rowIndicatorValue + 1);
break;
}
}
// Maybe we should check if we have ambiguous values?
if ((barcodeColumnCount.getValue().isEmpty) ||
(barcodeRowCountUpperPart.getValue().isEmpty) ||
(barcodeRowCountLowerPart.getValue().isEmpty) ||
(barcodeECLevel.getValue().isEmpty) ||
barcodeColumnCount.getValue()[0] < 1 ||
barcodeRowCountUpperPart.getValue()[0] +
barcodeRowCountLowerPart.getValue()[0] <
PDF417Common.MIN_ROWS_IN_BARCODE ||
barcodeRowCountUpperPart.getValue()[0] +
barcodeRowCountLowerPart.getValue()[0] >
PDF417Common.MAX_ROWS_IN_BARCODE) {
return null;
}
final barcodeMetadata = BarcodeMetadata(
barcodeColumnCount.getValue()[0],
barcodeRowCountUpperPart.getValue()[0],
barcodeRowCountLowerPart.getValue()[0],
barcodeECLevel.getValue()[0],
);
_removeIncorrectCodewords(codewords, barcodeMetadata);
return barcodeMetadata;
}