isByteString function

bool isByteString(
  1. String byStr, {
  2. required int length,
})

Implementation

bool isByteString(String byStr, {required int length}) {
  final str = byStr.startsWith(RegExp(r'0x', caseSensitive: false))
      ? byStr.substring(2)
      : byStr;
  return validators.matches(str, '^[0-9a-fA-F]{$length}') &&
      validators.isLength(str, length, length);
}