convert method
Actual barcode computation method, returns a stream of bool which represents the presence or absence of a bar
Implementation
@override
Iterable<bool> convert(String data) sync* {
data = adaptData(data);
final checksum = <int>[];
for (var codeIndex in shortestCode(data.codeUnits)) {
final codeValue = BarcodeMaps.code128[codeIndex]!;
yield* add(codeValue, BarcodeMaps.code128Len);
checksum.add(codeIndex);
}
// Checksum
var sum = 0;
for (var index = 0; index < checksum.length; index++) {
final code = checksum[index];
final mul = index == 0 ? 1 : index;
sum += code * mul;
}
sum = sum % 103;
yield* add(BarcodeMaps.code128[sum]!, BarcodeMaps.code128Len);
// Stop
yield* add(
BarcodeMaps.code128[BarcodeMaps.code128Stop]!, BarcodeMaps.code128Len);
// Termination Bars
yield true;
yield true;
}