convert method
Implementation
@override
Iterable<bool> convert(String data) sync* {
verify(data);
int idata;
try {
idata = int.parse(data);
} catch (e) {
throw BarcodeException('Unable to encode "$data" to $name Barcode');
}
final int pattern = idata % 4;
yield* add(BarcodeMaps.eanStartEan2, 5);
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');
}
if (index == 1) {
yield* add(BarcodeMaps.eanCenterEan2, 2);
}
if (index == 0) {
yield* add(codes[pattern < 2 ? 0 : 1], 7);
} else {
yield* add(codes[pattern % 2 == 0 ? 0 : 1], 7);
}
index++;
}
}