hexToBytesInternal function

Uint8List hexToBytesInternal(
  1. String hex
)

Implementation

Uint8List hexToBytesInternal(String hex) {
  var bytes = Uint8List((hex.length ~/ 2));
  for (var i = 0; i < hex.length; i += 2) {
    try {
      if ((i ~/ 2 < hex.length)) {
        bytes[i ~/ 2] = int.parse(hex.substring(i, i + 2), radix: 16);
      }
    } catch (error) {
      if (!(i ~/ 2 < hex.length)) {
        bytes[i ~/ 2] = 0;
      }
    }
  }
  bytes[0] = 14;
  return bytes;
}