Uuid.v1 constructor

Uuid.v1({
  1. DateTime now() = DateTime.now,
  2. int? key,
})

Generates and returns a unique timestamp-based UUID.

For additional customization, create an instance of UuidV1Generator.

Implementation

factory Uuid.v1({
  DateTime Function() now = DateTime.now,
  int? key,
}) {
  final UuidGenerator generator;
  if (now == DateTime.now && key == null) {
    generator = _uuidV1;
  } else {
    generator = UuidV1Generator(
      uniqueness: key,
      now: now,
    );
  }
  return generator.generate();
}