BasePreferences class abstract
--- PREFERENCE SYSTEM ARCHITECTURE ---
BasePreferences is the orchestrator for all persistent state in the app.
It provides a unified interface for two distinct storage backends:
- SharedPreferences: Fast, synchronous-style local disk I/O. Best for settings that need to be available instantly on UI startup.
- FlutterSecureStorage: Encrypted storage (Keychain/KeyStore). Best for tokens and sensitive user data.
Reactivity Model
This class doesn't just store data; it makes it reactive. The generated mixins
use ValueNotifiers that are initialized here. When you update a property:
- The
SharedPreferences/SecureStorageis updated (Disk). - The
ValueNotifieris triggered (In-Memory). - Any listening
ValueListenableBuilderoraddListeneris notified (UI).
Constructors
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
-
disposeGenerated(
) → void - Hook for code-generated disposal logic.
-
getBool(
String key, bool defaultValue) → bool -
--- STORAGE HELPERS (GETTERS) ---
Reads a boolean from
SharedPreferences. ReturnsdefaultValueif the key is missing. -
getDouble(
String key, double defaultValue) → double -
Reads a double from
SharedPreferences. -
getInt(
String key, int defaultValue) → int -
Reads an integer from
SharedPreferences. -
getSecureInternal(
String key) → Future< String?> - --- SECURE STORAGE INTERNALS --- Reads a value from the encrypted store (Keychain/KeyStore).
-
getString(
String key, String defaultValue) → String -
Reads a string from
SharedPreferences. -
getStringList(
String key, List< String> defaultValue) → List<String> -
Reads a list of strings from
SharedPreferences. No nested types allowed. -
init(
) → Future< void> - --- LIFECYCLE MANAGEMENT --- Initializes the storage engines and triggers code-generated setup.
-
initGenerated(
) → void - Hook for code-generated initialization logic.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setBool(
String key, bool value) → Future< bool> - --- STORAGE HELPERS (SETTERS) --- Persists a boolean to disk. Returns success/failure status.
-
setDouble(
String key, double value) → Future< bool> - Persists a double to disk.
-
setInt(
String key, int value) → Future< bool> - Persists an integer to disk.
-
setSecureInternal(
String key, String? value) → Future< void> - Writes (or deletes if null) a value in the encrypted store.
-
setString(
String key, String value) → Future< bool> - Persists a string to disk.
-
setStringList(
String key, List< String> value) → Future<bool> - Persists a string list to disk.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited