unique_id_generator 1.0.0
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