Uuid.v1 constructor

Uuid.v1({
  1. int? nodeId,
})

Generates a v1 (time-based) UUID.

The default implementation doesn't use a real MAC address as a node ID. Instead it generates a random node ID and sets the "multi-cast bit" as recommended by RFC 4122. A generated node ID will be kept in-memory and reused during the lifetime of a process, but won't be persisted.

Instead of using a generated node ID, you may specify one using nodeId. If the given node ID is larger than 48-bit, an ArgumentError is thrown.

Implementation

factory Uuid.v1({int? nodeId}) {
  final bytes = Uuid1Generator().generate(nodeId: nodeId);
  // We trust our own generator not to modify the bytes anymore.
  return Uuid._fromValidBytes(bytes);
}