hexToBin static method

Uint8List hexToBin(
  1. String? hexString
)

This method converts a given hexString to its byte representation.

Implementation

static Uint8List hexToBin(String? hexString) {
  if (hexString == null || hexString.length % 2 != 0) {
    throw Exception('odd hex string length');
  }

  return Uint8List.fromList([
    for (var i = 0; i < hexString.length; i += 2)
      int.parse(hexString[i] + hexString[i + 1], radix: 16)
  ]);
}