Skip to content

UUID type for Dart. Provides parsing, formatting, generation and comparison of UUIDs as defined by RFC 4122

License

Notifications You must be signed in to change notification settings

denixport/dart-uuid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UUID type for Dart

Build Status Pub GitHub

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 time-based v1, random-based v4, and namespace & name-based v5 UUIDs
  • Implements Comparable for UUID comparison and lexicographical sorting
  • Runs on Dart VM and in browser

RFC 4122 Version support:

  • v1, based on timestamp and MAC address (RFC 4122)
  • v2, based on timestamp, MAC address and POSIX UID/GID (DCE 1.1) Not planned
  • v3, based on MD5 hashing (RFC 4122) Not planned
  • v4, based on random numbers (RFC 4122)
  • v5, based on SHA-1 hashing (RFC 4122)

Requirements

  • Dart SDK >- 2.12.0
  • crypto package

Getting Started

Installation

  1. Add an entry in your pubspec.yaml for uuid_type
dependencies:
  uuid_type: ^2.0.0
  1. Run pub get (flutter packages get for Flutter)
  2. 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.