Uuid.nameUuidFromString constructor

Uuid.nameUuidFromString(
  1. Uuid namespace,
  2. String name
)

Generates a name-based UUID from a string name.

Parameters:

  • namespace: Namespace UUID for the name
  • name: String name to generate UUID from

Returns:

  • A deterministic UUID based on the namespace and name string

This is a convenience method that converts the string name to UTF-8 bytes and calls nameUuidFromBytes.

Example

final uuid = Uuid.nameUuidFromString(Uuid.NAMESPACE_DNS, 'example.com');
print(uuid.version); // 5

Implementation

factory Uuid.nameUuidFromString(Uuid namespace, String name) {
  return Uuid.nameUuidFromBytes(namespace, utf8.encode(name));
}