PreferencesRepository class

Manages app preferences and resolves each through a layered source stack.

Resolution precedence (highest first): forced (Remote Config _force_override_flags) > local override (SharedPreferences) > Remote Config value > the key's declared default. Remote Config lets the server control or force a preference; PrefSource records which layer answered.

Supports cloud sync by embedding the user's locally-set values as MessagePack in the avatar file uploaded to NTUT's portal (see syncUp/syncDown). Only values the user explicitly set are synced — server-controlled and default values are never baked into the payload. Sync runs only while logged in.

Constructors

PreferencesRepository({required TypedPreferenceStore store, required PortalService portalService, required AppDatabase database, required AuthRepository authRepository, required bool isLoggedIn()})

Properties

hashCode int
The hash code for this object.
no setterinherited
onUpdated Stream<void>
Emits whenever a resolved value may have changed (override set/reset or a Remote Config update).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

get<T>(PrefKey<T> key) Future<T>
Gets a preference's effective value, resolving the source stack.
init() Future<void>
Seeds Remote Config defaults from PrefKey.values and wires updates.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refresh() Future<void>
Forces a fresh Remote Config fetch and re-emits.
reset(PrefKey key) Future<void>
Removes a preference's local value, reverting to remote/default.
resolve(PrefKey key) Future<ResolvedPreference>
Resolves one preference by walking the source stack (highest first).
resolveAll() Future<List<ResolvedPreference>>
Resolves every preference through the source stack.
set<T>(PrefKey<T> key, T value) Future<void>
Sets a preference's local value and marks state dirty for cloud sync.
syncDown() Future<void>
Downloads the avatar and restores embedded preferences if present.
syncOnLaunch() Future<void>
Syncs preferences with the cloud on app launch.
syncUp() Future<void>
Uploads preferences embedded in the current avatar.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited