ThemeController class
Owns the theme mode, persists it, and exposes the resolved theme that the
UI applies as data-theme on the document root.
DOM application is delegated to apply so this controller stays unit-testable
without a browser; the live app passes a callback that sets the attribute and
prefersDark wired to matchMedia('(prefers-color-scheme: dark)').
Constructors
- ThemeController(SettingsStore _settings, {required bool prefersDark(), void onApply(ResolvedTheme theme)?})
- Creates a controller, restoring the persisted preference from settings.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
mode
→ Observable<
ThemeMode> -
The current preference (observable for the theme toggle UI).
final
- onApply → void Function(ResolvedTheme theme)?
-
Applies the resolved theme to the document (null in non-DOM tests).
final
- prefersDark → bool Function()
-
Reports whether the OS/browser currently prefers a dark scheme.
final
- resolved → ResolvedTheme
-
The theme actually rendered, resolving ThemeMode.system against the OS.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cycle(
) → void - Cycles light → dark → system → light (used by the header toggle).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refreshSystem(
) → void - Re-applies the resolved theme (call when the OS preference changes while in ThemeMode.system).
-
set(
ThemeMode next) → void - Sets the preference, persists it, and re-applies.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited