uuid_dash

pub package CI License: MIT

A Dart UUID library with Uint8List-based internals. Generates, parses, and encodes UUIDv4, UUIDv7, and UUIDv8.

Installation

dependencies:
  uuid_dash: ^0.2.0

Or:

dart pub add uuid_dash

Quick start

import 'package:uuid_dash/uuid_dash.dart';

void main() {
  final v4 = Uuid.newV4();
  final v7 = Uuid.nowV7();
  final v8 = Uuid.newV8(Uint8List.fromList(List.generate(16, (i) => i)));

  print('v4 $v4  version=${v4.version.value}');
  print('v7 $v7  version=${v7.version.value}');
  print('v8 $v8  version=${v8.version.value}');

  final parsed = Uuid.parse(v4.hyphenated);
  print('round-trip equal: ${parsed == v4}');
  print('urn:   ${v7.urn}');
  print('brace: ${v7.braced}');
  print('simple: ${v7.simple}');
}

API

Generation

Method Description
Uuid.newV4() Random UUID (v4).
Uuid.nowV7() v7 with the current time (shorthand for newV7(DateTime.now())).
Uuid.newV7(DateTime time) v7 at a specific time. Throws ArgumentError if time.millisecondsSinceEpoch is outside 0 ~ 2^48-1.
Uuid.newV8(Uint8List bytes) v8 from 16 user bytes; version/variant bits are forced. Throws ArgumentError if length ≠ 16.

Parsing & construction

Method Description
Uuid.parse(String input) Parses simple / hyphenated / braced / URN. Throws FormatException on invalid input.
Uuid.tryParse(String input) Same as parse, returns null on failure.
Uuid.fromBytes(Uint8List bytes) Constructs from 16 bytes (copied). Throws ArgumentError if length ≠ 16.
Uuid.tryFromBytes(Uint8List bytes) Same as fromBytes, returns null on failure.

Encoding

Getter Example
hyphenated / toString() 550e8400-e29b-41d4-a716-446655440000
simple 550e8400e29b41d4a716446655440000
braced {550e8400-e29b-41d4-a716-446655440000}
urn urn:uuid:550e8400-e29b-41d4-a716-446655440000

Properties

Getter Description
bytes A 16-byte copy of the internal Uint8List.
version Version enum (v4 / v7 / v8 / unknown).
variant High bits of byte 8; RFC 4122 is 2.

Supported UUID versions

Version Status
v4
v7
v8
v1, v3, v5, v6 Not yet implemented.

v4 and v7 use dart:math's Random.secure() (cryptographically secure).

License

This project is licensed under the MIT License.

Copyright (c) 2026 shenghaiyang.

Libraries

uuid_dash
A Dart UUID library.