decode static method

Uint8List decode(
  1. String hex
)

Implementation

static Uint8List decode(String hex) {
  String str = trimHex(hex);
  if (str.length % 2 != 0) {
    str = "0$str";
  }

  var result = Uint8List(str.length ~/ 2);
  for (int i = 0; i < str.length; i += 2) {
    final high = _hexDigit(str.codeUnitAt(i));
    final low = _hexDigit(str.codeUnitAt(i + 1));
    if (high == -1 || low == -1) {
      throw FormatException("Invalid hexadecimal string", hex);
    }
    result[i ~/ 2] = (high << 4) | low;
  }
  return result;
}