⚠️ FORK NOTICE: This repository is a fork of the original dart-uuid by Daegalus. maintained by Input Output Global, Inc. (IOG)Original README, License and Documentation.
Simple, fast generation of RFC4122 and RFC9562 UUIDs.
Features:
- Generate RFC4122 version 1, version 4, or version 5 UUIDs
- Supports RFC9562 version 6, version 7, and version 8
- Supported Platforms: Web, Server, iOS, Android, Linux, MacOS, Windows
- Cryptographically strong random number generation on all platforms
dependencies:
uuid_plus: ^0.1.0
import 'package:uuid_plus/uuid_plus.dart';
var uuid = Uuid();
Then create some ids ...
// Generate a v1 (time-based) id
uuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
// Generate a v4 (random) id
uuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'
// Generate a v5 (namespace-name-sha1-based) id
uuid.v5(Uuid.NAMESPACE_URL, 'www.google.com'); // -> 'c74a196f-f19d-5ea9-bffd-a2742432fc9c'
The library comes with a comprehensive test suite. Here's how to run the tests:
To run all tests:
dart test
To run specific tests:
# Run a specific test file
dart test test/v4_test.dart
# Run a specific test group (by name)
dart test test/v7_test.dart --name="UuidV7"
# Run a specific individual test
dart test test/v7_test.dart --name="Direct UuidV7 Class Tests"
# Run tests matching a pattern
dart test test/v7_test.dart --name="timestamp"
# Run multiple test files
dart test test/v4_test.dart test/v7_test.dart
To run all tests:
# Run all tests in Chrome
dart test -p chrome
# Run only UUID v7 tests in Chrome
dart test test/v7_test.dart --name="UuidV7" -p chrome
# Run on specific browsers
dart test -p chrome,firefox
# Run with increased timeout for slow tests
dart test -p chrome --timeout=2x
For debugging in the browser:
# Basic debugging - pauses for you to connect DevTools
dart test test/v4_test.dart -p chrome --pause-after-load
# Debug a specific test group
dart test test/v7_test.dart --name="UuidV7" -p chrome --pause-after-load --timeout=10x
# Debug a specific test with extended timeout
dart test test/v7_test.dart --name="Direct UuidV7 Class Tests" -p chrome --pause-after-load --timeout=10x
This will open Chrome and pause execution, allowing you to use Chrome DevTools for debugging.
See CHANGELOG
This package is a fork of dart-uuid originally created by Yulian Kuncheff.
The original package is licensed under the MIT License. This fork maintains the same license with additional copyright notice for Input Output Global, Inc. (IOG).