newIdempotencyKey function

String newIdempotencyKey()

Fresh ULID for one logical mutation (18 ยง8).

Implementation

String newIdempotencyKey() {
  var time = DateTime.now().millisecondsSinceEpoch;
  var ts = '';
  for (var i = 0; i < 10; i++) {
    ts = _crockford[time % 32] + ts;
    time = time ~/ 32;
  }
  final rs = List.generate(16, (_) => _crockford[_random.nextInt(32)]).join();
  return ts + rs;
}