tryFromHex function

Uint8List? tryFromHex(
  1. String input, {
  2. Base16Codec? codec,
})

Converts a Base-16 string to an 8-bit integer sequence, returning null instead of throwing when the input is not valid.

This is the non-throwing counterpart of fromHex. See fromHex for the meaning of codec.

Implementation

Uint8List? tryFromHex(
  String input, {
  Base16Codec? codec,
}) {
  try {
    return fromHex(input, codec: codec);
  } on FormatException {
    return null;
  }
}