unique_id_dart 1.0.0 copy "unique_id_dart: ^1.0.0" to clipboard
unique_id_dart: ^1.0.0 copied to clipboard

Generate unique IDs in Dart using Snowflake or UUID v4.

unique_id_dart #

English | δΈ­ζ–‡

Generate unique IDs in Dart using two strategies:

  • Short numeric IDs based on Snowflake.
  • Standard UUID v4 strings.

Getting started #

Add the dependency:

dependencies:
  unique_id_dart: ^1.0.0

Then run:

dart pub get

Usage #

import 'package:unique_id_dart/unique_id_dart.dart';

void main() {
  final shortId = uniqueId();
  final longId = uniqueId(shorter: false);

  print(shortId);
  print(longId);
}

API #

  • uniqueId({bool shorter = true})
    • true (default): Snowflake-based numeric ID.
    • false: UUID v4 string.

Notes #

  • Snowflake uses a fixed workerId and datacenterId internally. If you need multi-node uniqueness guarantees, consider exposing configuration or forking.
  • Run tests with dart test. See example/ for a runnable demo.
0
likes
160
points
31
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Generate unique IDs in Dart using Snowflake or UUID v4.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

snowflaker, uuid

More

Packages that depend on unique_id_dart