isHexBytes static method
Implementation
static bool isHexBytes(String v, {int? lengthInBytes}) {
assert(lengthInBytes == null || lengthInBytes >= 0);
int start = 0;
if (v.startsWith('0x') || v.startsWith('0X')) {
start = 2;
}
final len = v.length - start;
if ((len & 1) != 0) return false;
if (lengthInBytes != null && len != lengthInBytes * 2) {
return false;
}
for (var i = start; i < v.length; i++) {
final c = v.codeUnitAt(i);
if (!((c >= 48 && c <= 57) ||
(c >= 65 && c <= 70) ||
(c >= 97 && c <= 102))) {
return false;
}
}
return true;
}