RandomUidGenerator constructor

RandomUidGenerator({
  1. int bits = 120,
  2. Random? random,
})

Implementation

factory RandomUidGenerator({int bits = 120, Random? random}) {
  int randomBits;
  BigInt initialValue;
  if (bits != 120) {
    if (bits < 24) {
      throw RangeError.range(bits, 24, null, 'bits');
    }
    randomBits = bits - 4;
    initialValue = _bigInt9 << randomBits;
  } else {
    randomBits = 116;
    initialValue = _randomUidInitialValue;
  }
  random ??= Random();
  return RandomUidGenerator._(randomBits, initialValue, random);
}