This package provides implementation of Universally Unique Identifier (UUID) for Dart, and supports generation, parsing and formatting of UUIDs.
Features:
- Creates UUID from string and byte-array, as well as GUID and URN strings
- Provides access to variant, version and byte data of UUID
- Generates RFC4122 version 1, version 4, or version 5 UUIDs
- Implements
Comparable
for UUID comparison and lexicographical sorting - Runs in web, server, and flutter
RFC Version support:
- v1, based on timestamp and MAC address
- v2, based on timestamp, MAC address and POSIX UID/GID (DCE 1.1) Not planned
- v3, based on MD5 hashing Not planned
- v4, based on random numbers
- v5, based on SHA-1 hashing
- v6, A re-ordering of UUID version 1 so it is sortable as an opaque sequence of bytes
- v7, An entirely new time-based UUID bit layout sourced from the widely implemented and well known Unix Epoch timestamp source
- v8, A free-form UUID format which has no explicit requirements except maintaining backward compatibility.
- Dart SDK >= 2.12.0
crypto
package
- Add an entry in your
pubspec.yaml
foruuid_type
dependencies:
uuid_type: ^2.1.0
- Run
pub get
(flutter packages get
for Flutter) - Import
import 'package:uuid_type/uuid_type.dart';
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
See CHANGELOG
Please file bugs and feature requests at the issue tracker.