ThemeController class
Object which controls the behavior of the theme. This is the object provided through the widget tree.
This implementation is hidden from the external uses.
Instead ThemeCommand
is exposed which is inherited by this class.
ThemeCommand
is a reduced API to ThemeController.
- Inheritance
-
- Object
- ChangeNotifier
- ThemeController
Constructors
-
ThemeController({required String providerId, required List<
AppTheme> themes, required String? defaultThemeId, required bool saveThemesOnChange, required bool loadThemeOnInit, ThemeChanged? onThemeChanged, ThemeControllerHandler? onInitCallback}) -
Controller which handles updating and controlling current theme.
themes
determine the list of themes that will be available.themes
cannot have conflictingid
parameters If conflictingid
s were found AssertionError will be thrown.
Properties
-
allThemes
→ List<
AppTheme> -
Returns the list of all themes.
no setter
- currentThemeId → String
-
Get the current theme id
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- providerId → String
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- theme → AppTheme
-
Get the current theme
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
addTheme(
AppTheme newTheme) → void - Adds the given theme dynamically.
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
forgetSavedTheme(
) → Future< void> - Removes last saved theme configuration.
-
hasTheme(
String themeId) → bool - Returns whether there is a theme with the given id.
-
loadThemeFromDisk(
) → Future< void> - Loads previously saved theme from disk. If this fails(no previous saved theme) it will be ignored. (No exceptions will be thrown)
-
nextTheme(
) → void -
Cycle to next theme in the theme list.
The sequence is determined by the sequence
specified in the ThemeProvider in the
themes
parameter. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
removeTheme(
String themeId) → void - Removes the theme with the given id dynamically.
-
saveThemeToDisk(
) → Future< void> - Saves current theme to disk.
-
setTheme(
String themeId) → void - Selects the theme by the given theme id. Throws an AssertionError if the theme id is not found.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited