AppThemeManager class

Entry point for initializing, switching and reading the application theme.

The theme state lives in a single app-wide bloc, so switching themes works from anywhere (including code with no BuildContext) and only swaps the ThemeData given to your MaterialApp: the navigation stack and page state are preserved.

Constructors

AppThemeManager()
factory

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

appThemes → List<AppTheme>
The themes passed to init.
no setter
currentTheme → AppTheme
The AppTheme (key and data) currently applied.
no setter
currentThemeKey → String
The key of the theme currently applied.
no setter
initialThemeData → ThemeData?
The theme data resolved during init (saved theme, else system brightness, else first).
no setter
instance → AppThemeManager
Gets the singleton instance of AppThemeManager.
no setter
isInitialized → bool
Whether init has completed.
no setter

Static Methods

changeTheme({BuildContext? context, required String themeKey}) → void
Switches the whole app to the theme registered under themeKey and persists it.
getCurrentTheme({BuildContext? context}) → ThemeData
Returns the ThemeData currently applied.
init({required List<AppTheme> themes}) → Future<void>
Initializes the theme manager with the supported themes.