neouuid

Fast and idiomatic UUIDs (Universally Unique Identifiers) in Dart.

Binary on pub.dev Code coverage Github action status Dartdocs Style guide

This library decodes and generates UUIDs, 128-bits represented as 32 hexadecimal digits:

ba6eb330-4f7f-11eb-a2fb-67c34e9ac07c

Usage

The generator supports three different UUID modes:

  • v1: Guaranteed unique, unless generated from the same computer at the same time.
  • v4: Completely random, 2^128 possible combinations make it almost impossible to repeat.
  • v5: Non-random, generated by providing an input and namespace string.

Performance & Compatibility

This package is intended to work identically and well in both the standalone Dart VM, Flutter, and web builds of Dart and Flutter (both in DDC and Dart2JS). Contributions are welcome to add special-cased that improves performacne for a specific platform (as long as there is a fallback for other platforms).

Benchmarks

Package Equivalent to Uuid.parse
neouuid 01.55us
uuid 15.66us
uuid_type 00.78us

As of 2022-07-22 on a Macbook Pro (M1), uuid_type is ~2x faster:

dart benchmark/neouuid_parse.dart
dart benchmark/uuid_parse.dart
dart benchmark/uuid_type_parse.dart

This is mainly due to this package using int.parse instead of building up a byte buffer from hexadecimel character matches.

Contributing

Some inspiration:

Libraries

neouuid
Fast and idiomatic UUIDs (Universally Unique Identifiers) in Dart.