UUID type for Dart
This package provides implementation of Universally Unique Identifier (UUID) for Dart, and supports generation, parsing and formatting of UUIDs.
Features:
x
Creates UUID from string and byte-array, as well as GUID and URN stringsx
Provides access to variant, version and byte data of UUIDx
Generates RFC4122 time-based v1, random-based v4, and namespace & name-based v5 UUIDsx
ImplementsComparable
for UUID comparison and lexicographical sortingx
Runs on Dart VM and in browser
RFC 4122 Version support:
x
v1, based on timestamp and MAC address (RFC 4122)x
v4, based on random numbers (RFC 4122)x
v5, based on SHA-1 hashing (RFC 4122)
Requirements
- Dart SDK >- 2.12.0
crypto
package
Getting Started
Installation
- Add an entry in your
pubspec.yaml
foruuid_type
dependencies:
uuid_type: ^2.0.0
- Run
pub get
(flutter packages get
for 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.