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; } }