UUID type for Dart
This package provides implementation of Universally Unique Identifier (UUID) for Dart, and supports generation, parsing and formatting of UUIDs.
Features
xCreates UUIDs from strings and byte arrays, including GUID and URN stringsxProvides access to UUID variant, version, and byte dataxGenerates RFC 9562 versions 1, 4, 5, 6, and 7 UUIDsxImplementsComparablefor UUID comparison and lexicographical sortingxRuns on the web, server, and Flutter
RFC version support
xv1, based on timestamp and MAC addressv2, based on timestamp, MAC address and POSIX UID/GID (DCE 1.1) Not plannedv3, based on MD5 hashing Not plannedxv4, based on random numbersxv5, based on SHA-1 hashingxv6, a time-ordered reordering of UUID version 1xv7, a Unix Epoch time-based UUIDv8, A free-form UUID format which has no explicit requirements except maintaining backward compatibility.
Requirements
- Dart SDK ^3.8.0
cryptopackage
Getting Started
Installation
- Add an entry in your
pubspec.yamlforuuid_type
dependencies:
uuid_type: ^2.1.0
- Run
pub get(flutter packages getfor Flutter) - Import
import 'package:uuid_type/uuid_type.dart';
Usage
Generate UUIDs
import 'package:uuid_type/uuid_type.dart';
void main() {
var u = TimeUuidGenerator().generate();
print(u.toString());
u = NameUuidGenerator(NameUuidGenerator.urlNamespace).generateFromString('https://dart.dev/');
print(u.toString());
u = RandomUuidGenerator().generate();
print(u.toString());
}
See more examples and documentation.
Release notes
See CHANGELOG
Features and Bugs
Please file bugs and feature requests at the issue tracker.