convert method
Implementation
@override
Iterable<bool> convert(String data) sync* {
if (data.length <= 8) {
data = upceToUpca(data);
}
data = checkLength(data, maxLength);
final int first = data.codeUnitAt(0);
final int last = data.codeUnitAt(11);
try {
data = upcaToUpce(data);
} on BarcodeException {
if (fallback) {
yield* const BarcodeUpcA().convert(data);
return;
}
rethrow;
}
yield* add(BarcodeMaps.eanStartEnd, 3);
final int? parityRow = BarcodeMaps.upce[last];
final int? parity = first == 0x30 ? parityRow : parityRow! ^ 0x3f;
int index = 0;
for (final int code in data.codeUnits) {
final List<int>? codes = BarcodeMaps.ean[code];
if (codes == null) {
throw BarcodeException('Unable to encode "${String.fromCharCode(code)}" to $name Barcode');
}
yield* add(codes[(parity! >> index) & 1 == 0 ? 1 : 0], 7);
index++;
}
yield* add(BarcodeMaps.eanEndUpcE, 6);
}