decodeHex static method

Uint8List decodeHex(
  1. String value
)

Decodes even-length hexadecimal without prefixes or whitespace.

Implementation

static Uint8List decodeHex(String value) {
  if (value.length.isOdd || !_hexPattern.hasMatch(value)) {
    throw InvalidInputException('Invalid canonical hexadecimal input');
  }

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