Flutter UIKit only.
setPreferredTheme is available in the Flutter UIKit from 4.20.20. Other platforms switch theme through Dynamic UI or the device appearance setting.Overview
By default the UIKit resolves its theme from thepreferred_theme value in your config.json at startup. setPreferredTheme lets you override that value at runtime, and the whole UIKit re-themes immediately — no restart, no config re-sync.
Flutter
Styles
How It Works
1
Call the API
AmityUIKit().setPreferredTheme(style) updates the preferred theme held on the ConfigRepository singleton.2
Whole tree re-themes
Every base page, component, and element already watches the config provider, so the change propagates to the entire UIKit tree immediately.
3
Overrides config.json
The runtime value takes precedence over
preferred_theme from config.json for the rest of the app session.The override lives in memory for the current app session. It is not persisted by the UIKit — on the next launch the theme resolves from
config.json again. Persist the user’s choice yourself (e.g. in SharedPreferences) and re-apply it on startup if you want it to stick.Persisting the choice
Save the selection and restore it before your app renders the UIKit:Flutter
restorePreferredTheme() in main() before runApp().
When to Use
✅ In-app light / dark toggle driven by a user setting ✅ Following the device appearance without an app restart ✅ Quick theme experiments during development For remote, non-engineering-driven brand/token changes, use Dynamic UI instead.Next Steps
Dynamic UI
Remote, config-driven theming
Component Styling
Per-component overrides