fix: harden server-scoped state

This commit is contained in:
edde746
2026-06-04 13:47:06 +02:00
parent 79c06b82d3
commit 145881318e
65 changed files with 358 additions and 360 deletions
+9
View File
@@ -467,6 +467,15 @@ class SettingsService extends BaseSharedPreferencesService {
/// Synchronous access to the singleton, or null if not yet initialized.
static SettingsService? get instanceOrNull => _cachedInstance;
/// Synchronous access to the bootstrapped singleton.
static SettingsService get instance {
final instance = _cachedInstance;
if (instance == null) {
throw StateError('SettingsService has not been initialized. Call SettingsService.getInstance() first.');
}
return instance;
}
/// Drop the cached singleton so the next [getInstance] call rebuilds against
/// the current SharedPreferences state. Test-only — pair with
/// [BaseSharedPreferencesService.resetForTesting].