toBytes static method

Uint8List toBytes(
  1. String hex
)

Implementation

static Uint8List toBytes(String hex) {
  int length = hex.length;
  if (length % 2 != 0) {
    hex = '0$hex';
    length++;
  }
  List<int> s = hex.toUpperCase().codeUnits;
  Uint8List retBytes = Uint8List(length >> 1);
  for (int i = 0; i < length; i += 2) {
    retBytes[i >> 1] = ((_getCharHex(s[i]) << 4) | _getCharHex(s[i + 1]));
  }
  return retBytes;
}