ObjectId class Null safety

ObjectId

This class allows you to create and manipulate bson ObjectIds.

Example:

final id = ObjectId();
final id2 = ObjectId.fromHexString('5f527e9b350aa5f9709daf16');
final id3 = ObjectId.fromBytes(
  [95, 82, 126, 187, 124, 177, 57, 83, 165, 119, 211, 48],
);
final id4 = ObjectId.fromValues(timestamp, processUnique, counter);

Constructors

ObjectId()
Creates ObjectId.
ObjectId.fromBytes(List<int> bytes)
Creates ObjectId from bytes.
ObjectId.fromHexString(String hexString)
Creates ObjectId from hex string.
ObjectId.fromTimestamp(DateTime timestamp)
Creates ObjectId from provided timestamp.
ObjectId.fromValues(int millisecondsSinceEpoch, int processUnique, int counter)
Creates ObjectId from provided values.

Properties

bytes Uint8List
ObjectId bytes.
read-only
hashCode int
The hash code for this object.
read-only, override
hexString String
Returns hex string for current ObjectId.
read-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
timestamp DateTime
Returns the generation date (accurate up to the second) that this ObjectId was generated.
read-only

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

isValid(String hexString) bool
Whether hexString is a valid ObjectId

Constants

byteLength → const int
Length of the ObjectId in bytes.
12
hexStringLength → const int
Length of the ObjectId hexString.
byteLength * 2