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 = checkLength(data, maxLength);
// Start
yield* add(BarcodeMaps.eanStartEnd, 3);
var index = 0;
for (var code in data.codeUnits) {
final codes = BarcodeMaps.ean[code];
if (codes == null) {
throw BarcodeException(
'Unable to encode "${String.fromCharCode(code)}" to $name Barcode');
}
if (index == 6) {
yield* add(BarcodeMaps.eanCenter, 5);
}
yield* add(codes[index < 6 ? 0 : 2], 7);
index++;
}
// Stop
yield* add(BarcodeMaps.eanStartEnd, 3);
}