toHex method

  1. @visibleForTesting
String toHex(
  1. String data
)
inherited

Computes a hexadecimal representation of the barcode, mostly for testing purposes

Implementation

@visibleForTesting
String toHex(String data) {
  var intermediate = '';
  for (var bit in convert(data)) {
    intermediate += bit ? '1' : '0';
  }

  var result = '';
  while (intermediate.length > 8) {
    final sub = intermediate.substring(intermediate.length - 8);
    result += int.parse(sub, radix: 2).toRadixString(16);
    intermediate = intermediate.substring(0, intermediate.length - 8);
  }
  result += int.parse(intermediate, radix: 2).toRadixString(16);

  return result;
}