convert method

  1. @override
Iterable<bool> convert(
  1. String data
)
override

Implementation

@override
Iterable<bool> convert(String data) sync* {
  data = adaptData(data);

  final List<int> checksum = <int>[];

  for (final int codeIndex in shortestCode(data.codeUnits)) {
    final int codeValue = BarcodeMaps.code128[codeIndex]!;
    yield* add(codeValue, BarcodeMaps.code128Len);
    checksum.add(codeIndex);
  }

  int sum = 0;
  for (int index = 0; index < checksum.length; index++) {
    final int code = checksum[index];
    final int mul = index == 0 ? 1 : index;
    sum += code * mul;
  }
  sum = sum % 103;
  yield* add(BarcodeMaps.code128[sum]!, BarcodeMaps.code128Len);

  yield* add(BarcodeMaps.code128[BarcodeMaps.code128Stop]!, BarcodeMaps.code128Len);

  yield true;
  yield true;
}