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

A Dart library for generating unique identifiers with customizable prefixes and lengths.

Unique ID Generator πŸš€

A Dart library for generating unique identifiers with customizable prefixes and lengths. It supports both random-based and timestamp-based ID generation, making it suitable for database records, user sessions, or other unique identifier needs.

Features ✨ #

  • πŸ†” Generate random unique IDs with customizable prefixes and lengths.
  • ⏰ Generate timestamp-based unique IDs with a hashed component for uniqueness.
  • πŸͺΆ Lightweight and dependency-minimal (only uses crypto for hashing).
  • πŸ§ͺ Fully tested with unit tests.

Installation πŸ“¦ #

Add the following to your pubspec.yaml:

dependencies:
  unique_id_generator: ^1.0.0

Then run:

dart pub get

Usage πŸ› οΈ #

import 'package:unique_id_generator/unique_id_generator.dart';

void main() {
  // Generate a random ID
  final randomId = UniqueIdGenerator.generateRandomId(prefix: 'user_', length: 12);
  print('Random ID: $randomId'); // e.g., user_aB7x9pL2qW8

  // Generate a timestamp-based ID
  final timestampId = UniqueIdGenerator.generateTimestampId(prefix: 'session_');
  print('Timestamp ID: $timestampId'); // e.g., session_1634567890123-4a8b2c1d
}

Usage Roadmap πŸ—ΊοΈ #

The following features and improvements are planned for future releases:

  • πŸ”’ Custom Character Sets: Allow users to define custom character sets for random ID generation (e.g., numeric-only or alphanumeric).
  • πŸ›‘οΈ Enhanced Security: Add options for cryptographically secure random IDs using additional algorithms.
  • πŸ“š Extended Documentation: Provide more examples and use cases, including integration with Flutter apps.
  • βš™οΈ Configuration Options: Introduce a configuration class to set global defaults for prefixes and lengths.
  • 🌐 Localization Support: Add support for localized timestamp formats in timestamp-based IDs.

Running Tests βœ… #

To run the tests, use:

dart test

Contributing 🀝 #

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License πŸ“œ #

MIT License

2
likes
160
points
77
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart library for generating unique identifiers with customizable prefixes and lengths.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

crypto, flutter

More

Packages that depend on unique_id_generator