Settings Repository
Component Detail
Data Layer
low complexity
mobilebackend
0
Dependencies
1
Dependents
1
Entities
0
Integrations
Description
Data access layer that abstracts both the local key-value store (shared_preferences) and the remote REST API backend behind a single clean interface. Handles serialization and deserialization of the UserSettings model, manages cache invalidation, and ensures writes to the local store are reflected to the server when connectivity is available. Belongs to the backend user→settings one-to-one relationship.
settings-repository
Responsibilities
- Persist UI preferences locally using shared_preferences with type-safe accessors
- Synchronize server-synced preferences (notifications, language) via REST API
- Provide a unified UserSettings model combining both storage backends
- Handle offline writes with deferred sync when connectivity is restored
Interfaces
loadSettings(String userId) Future<UserSettings>
saveSettings(UserSettings settings) Future<void>
loadLocalPreference<T>(String key) T?
saveLocalPreference<T>(String key, T value) Future<void>
fetchRemoteSettings(String userId) Future<Map<String, dynamic>>
pushRemoteSettings(String userId, Map<String, dynamic> settings) Future<void>
clearLocalSettings() Future<void>
getDefaultSettings() UserSettings