Package selection guidance compiled from public package information, community data, and project usage.
A high-performance, cross-platform ObjectId implementation for Dart, designed for efficient generation and handling of unique identifiers across multiple platforms. Built for speed and compatibility, it supports Android, iOS, Web, macOS, Windows, and Linux. Ideal for applications requiring secure, globally unique IDs—such as databases or distributed systems—this package ensures consistency and reliability without sacrificing performance. It is particularly useful in backend services or real-time apps where ID uniqueness and generation speed are critical.
Use cases
Database document ID generation
Distributed system identifier creation
Real-time application data synchronization
Secure session token generation
Cross-platform app data tracking
Key features
Blazing fast ID generation
Cross-platform compatibility
Thread-safe implementation
Compact 12-byte ID format
Supports timestamp, machine, process, and counter components
Easy integration with Flutter apps
Suitable for
Developers building scalable backend services
Apps requiring unique identifiers across platforms
Projects using MongoDB or similar databases
High-throughput real-time applications
Teams prioritizing performance and portability
Considerations
Not suitable for cryptographic secrets
Requires careful handling in multi-threaded environments
Does not provide UUID compatibility
Limited to ObjectId-specific use cases
No built-in validation utilities
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
ObjectId
Blazing fast, cross-platform ObjectId implementation for the dart language!
final id = ObjectId(); // That's all 🔥😮!print(id); // it's working! => 5f52c805df41c9df948e6135
Documentation
Constructors
ObjectId()
Creates an ObjectId instance based on current timestamp, process unique and counter.
final id = ObjectId();
print(id.hexString); // => 5f52c805df41c9df948e6135
ObjectId.fromHexString(String hexString)
Creates ObjectId from a 24-character hex string.
// Useful for mapping hex strings from APIs or MongoDBfinal id = ObjectId.fromHexString('5f52c805df41c9df948e6135');
print(id == ObjectId.fromHexString(id.hexString)); // => true
ObjectId.fromBytes(List<int> bytes)
Creates ObjectId from a 12-byte array.
// Perfect for storing ObjectId in binary formatfinal id = ObjectId.fromBytes([95, 82, 205, 121, 180, 195, 28, 88, 32, 47, 183, 78]);
print(id.hexString); // => 5f52cd79b4c31c58202fb74e// Retrieve bytes with the bytes propertyfinal id2 = ObjectId.fromBytes(id.bytes);
print(id == id2); // => true
ObjectId.fromValues(int millisecondsSinceEpoch, int processUnique, int counter)