SafeIntId class

SafeIntId config and methods. Please see README.md for details.

Constructors

SafeIntId({int firstYear = 2023, Random? random, int randomValues = 1024})
Create new SafeIntId generator.

Properties

firstYear int
The first year you use this ID.
latefinal
hashCode int
The hash code for this object.
no setterinherited
lastSafeYear int
Last year this ID will be safe.
latefinal
random Random
Random generator.
latefinal
randomValues int
Number of possible random values per millisecond. Makes ID more unique in exchange for safeYears.
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
safeYears int
How many years since firstYear this ID will be safe.
latefinal

Methods

getCreatedAt(int id, {bool isUtc = false}) DateTime
Get DateTime when given id was created at.
getId() int
Get a new uncoordinated unique ID that fits Number.MAX_SAFE_INTEGER on web platform for long enough time.
incId() int
The same as getId but increments counter instead of using random value. Counter resets to zero each millisecond, blocks reaching randomValues. Use await incIdAsync() if hot loop for less than 1 millisecond burns.
incIdAsync() Future<int>
The same as incId but async.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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