SafeIntId constructor

SafeIntId({
  1. int firstYear = 2023,
  2. Random? random,
  3. int randomValues = 1024,
})

Create new SafeIntId generator.

Implementation

SafeIntId({
  this.firstYear = 2023,
  Random? random,
  int randomValues = 1024,
}) {
  _firstYearMillis = DateTime.utc(firstYear).millisecondsSinceEpoch;
  this.random = random ?? Random();
  this.randomValues = max(randomValues, 1);
  safeYears =
      pow(2, 53) ~/ (this.randomValues * 1000 * 60 * 60 * 24 * 365.2425);
  lastSafeYear = firstYear + safeYears - 1;
}