isHexString function

bool isHexString(
  1. String value,
  2. int length
)

Implementation

bool isHexString(String value, int length) {
  if (value.length != length * 2 + 2) {
    return false;
  }
  try {
    HEX.decode(value.substring(2));
    return true;
  } catch (_) {
    return false;
  }
}