toUnitList function

Uint8List toUnitList(
  1. String str
)

Implementation

Uint8List toUnitList(String str) {
  var length = str.length;
  if (length % 2 != 0) {
    str = '0$str';
    length++;
  }
  final s = str.toUpperCase().codeUnits;
  final bArr = Uint8List(length >> 1);
  for (var i = 0; i < length; i += 2) {
    bArr[i >> 1] = (hex(s[i]) << 4) | hex(s[i + 1]);
  }
  return bArr;
}