canStart static method

Future<bool> canStart(
  1. String stateId
)

Returns true if the user can start this free state right now.

Implementation

static Future<bool> canStart(String stateId) async {
  final key = 'last_$stateId';
  final today = _todayKey();

  // Check memory cache first (fast path, no IndexedDB).
  if (_cache.containsKey(key)) {
    return _cache[key] != today;
  }

  // Fall back to Hive (first check this session).
  final box = await _openBox();
  final lastUsed = box.get(key) as String?;
  if (lastUsed != null) _cache[key] = lastUsed;
  if (lastUsed == null) return true; // First ever use.
  return lastUsed != today;
}