createUint8ListFromHexString static method

Uint8List createUint8ListFromHexString(
  1. String hex
)

Creates a Uint8List by a hex string.

Implementation

static Uint8List createUint8ListFromHexString(String hex) {
  var result = Uint8List(hex.length ~/ 2);
  for (var i = 0; i < hex.length; i += 2) {
    var num = hex.substring(i, i + 2);
    var byte = int.parse(num, radix: 16);
    result[i ~/ 2] = byte;
  }

  return result;
}