createSlot method

SaveSlotMeta createSlot(
  1. String displayName
)

Creates a new slot with a freshly-generated, guaranteed-unique id (even across a burst of rapid calls in the same millisecond). createdAtMs/lastPlayedAtMs both start at nowMsClamped() — the same anti-clock-rewind clock every time-gated system in this package uses, never raw DateTime.now().

Implementation

SaveSlotMeta createSlot(String displayName) {
  if (displayName.trim().isEmpty) {
    throw ArgumentError.value(
      displayName,
      'displayName',
      'must not be empty',
    );
  }
  final limit = maxSlots;
  if (limit != null && _slotList.length >= limit) {
    throw StateError('SaveSlotManager already has the max $limit slot(s)');
  }
  final now = nowMsClamped();
  final id = _generateUniqueId(now);
  final slot = SaveSlotMeta(
    id: id,
    displayName: displayName,
    createdAtMs: now,
    lastPlayedAtMs: now,
  );
  _slotList.add(slot);
  _scheduleSave();
  return slot;
}