Overview
Location:lib/logic/settings_logic.dart
The SettingsLogic class manages user preferences and app configuration, including onboarding state, locale preferences, and UI settings. It uses ThrottledSaveLoadMixin for automatic persistence to local storage.
Registration
Properties
Tracks whether the user has completed the intro/onboarding flow. Default:
false.When false, the app shows the IntroScreen on launch. Set to true after completing onboarding.Tracks whether the user has dismissed the search help message. Default:
false.Tracks the open/closed state of the search panel. Default:
true.The currently selected locale code (e.g., “en”, “zh”). Default:
null (system locale).The last viewed wonder index for preserving navigation state. Default:
null.Whether to use blur effects in the UI. Returns
false on Android (performance), true on other platforms.Methods
changeLocale()
Changes the app’s locale and reloads localized content.value: The newLocaleto apply
- Updates
currentLocale.valuewith the language code - Calls
localeLogic.loadIfChanged()to load translations - Reinitializes
wondersLogicandtimelineLogicwith localized data
Persistence Methods
Inherited fromThrottledSaveLoadMixin:
copyFromJson() - Deserializes settings from JSON:
hasCompletedOnboardinghasDismissedSearchMessagecurrentLocaleisSearchPanelOpenprevWonderIndex(stored aslastWonderIndex)
Usage Examples
Check Onboarding Status
Watch Settings Changes
Complete Onboarding
Initialization
Settings are loaded during app bootstrap inAppLogic.bootstrap():
File Storage
Settings are persisted to:- File:
settings.dat - Format: JSON
- Location: App documents directory (via
path_provider)
Related
- LocaleLogic - Localization management
- AppLogic - App bootstrap and initialization
- State Management - ValueNotifier pattern