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

Twitter's snowflaker algorithm implementation in Dart.

Snowflake ID Generator #

A Dart library for generating unique, sortable ID strings using the Twitter's Snowflake algorithm.

Features #

  • Thread-safe generation of unique IDs.
  • Each ID contains a timestamp with millisecond precision.
  • Customizable worker and datacenter identifiers.

Usage #

Add the following to your pubspec.yaml file:

dependencies:
  snowflaker: ^1.0.0

Then import the library:

import 'package:snowflaker/snowflaker.dart';

To generate a new ID, create a new instance of snowflaker and call its nextId() method:


// Create a new instance of snowflaker with a worker ID of 1 and a datacenter ID of 1.
final snowflaker = Snowflaker(workerId: 1, datacenterId: 1);

// Generate a new ID.
final id = snowflaker.nextId();
2
likes
0
pub points
62%
popularity

Publisher

verified publisherlazebny.io

Twitter's snowflaker algorithm implementation in Dart.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on snowflaker