Nonce.unique constructor

Nonce.unique([
  1. int length = 32
])

Constructs a Nonce that's unique from every other Nonce that's been generated by this global instance.

Implementation

factory Nonce.unique([int length = 32]) {
  assert(length > 0);
  var value = generate(length: length);
  while (_uniqueNonces.contains(value)) {
    value = generate(length: length);
  }
  _uniqueNonces.add(value);
  return Nonce._(value);
}