UserPrefsDatasource class

Thin wrapper around SharedPreferences for non-secret, device-local user prefs. Use flutter_secure_storage for anything sensitive (API keys, auth tokens). This class is safe to instantiate multiple times — all instances talk to the same underlying storage.

Constructors

UserPrefsDatasource({SharedPreferences? prefs})

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearHomeCache() → Future<void>
Clears all home first-paint cache entries. Called on sign-out so the next user doesn't see the previous user's streak / domain list flash before their own data loads.
getCachedDomains() → Future<List<CachedDomain>>
Cached projection of `MyCurriculumDomains` — id/name/slug only, capped to keep the blob tiny. Reads return an empty list if missing or stale.
getCachedDueCount() → Future<int?>
getCachedStreak() → Future<int?>
getLastActiveOrgId() → Future<String?>
getLastUsedMode() → Future<String>
Returns 'personal' or 'org'. Defaults to 'personal' when unset.
getLocale() → Future<Locale?>
User-selected UI language. Returns null when unset, meaning "follow the device/OS locale" — the app then leaves MaterialApp.locale null and Flutter resolves against MaterialApp.supportedLocales. Only the language subtag is stored (e.g. 'fr'), which is all the app's supported locales distinguish.
getMasteryIntroSeen() → Future<bool>
One-time flag for the mastery-ladder intro banner shown at the top of TopicTreeScreen. The banner replaces the standalone /onboarding/mastery screen — the explanation only surfaces when the user actually opens a domain's topic tree and goes away after dismissal.
getReviewIntroSeen() → Future<bool>
One-time flag for the spaced-repetition intro banner shown at the top of ReviewSessionScreen. The banner replaces the standalone /onboarding/review screen — the explanation only surfaces when the user actually lands in the review flow and goes away forever after they dismiss it.
getThemeMode() → Future<ThemeMode>
User-selected theme. Defaults to ThemeMode.system when unset or when the stored value isn't a recognised ThemeMode.name (e.g. corruption).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setCachedDomains(List<CachedDomain> domains) → Future<void>
setCachedDueCount(int value) → Future<void>
setCachedStreak(int value) → Future<void>
setLastActiveOrgId(String orgId) → Future<void>
setLastUsedMode(String mode) → Future<void>
setLocale(Locale? locale) → Future<void>
Persists the chosen language, or clears it (follow-system) when locale is null.
setMasteryIntroSeen(bool seen) → Future<void>
setReviewIntroSeen(bool seen) → Future<void>
setThemeMode(ThemeMode mode) → Future<void>
toString() → String
A string representation of this object.
inherited

Operators

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

Constants

homeCacheMaxAge → const Duration