isValidUUIDFormat static method

bool isValidUUIDFormat({
  1. String fromString = '',
  2. Uint8List? fromByteList,
  3. bool noDashes = false,
})

Validates that the input is exactly a 128-bit hexadecimal value.

String input must use the canonical UUID 8-4-4-4-12 layout. Set noDashes to true to instead require exactly 32 hexadecimal characters. This method does not validate UUID version or variant bits.

Byte input must contain exactly 16 bytes. When fromByteList is provided, it takes precedence over fromString.

Implementation

static bool isValidUUIDFormat({
  String fromString = '',
  Uint8List? fromByteList,
  bool noDashes = false,
}) {
  if (fromByteList != null) {
    return fromByteList.length == 16;
  }

  final regex = noDashes ? _hex128WithoutDashes : _hex128WithDashes;
  return regex.hasMatch(fromString);
}