Themed class

Manages theme switching and persistence for Flutter applications.

Themed is a singleton that handles:

  • Built-in light and dark themes
  • Custom theme creation and management
  • Automatic theme persistence (when storage adapter is provided)
  • Reactive theme updates via ValueNotifier

Constructors

Themed()
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
themeNotifier ValueNotifier<ThemeData>
getter/setter pair

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

availableThemes List<String>
Returns a list of all available theme names.
no setter
currentTheme ThemeData
Returns the currently active ThemeData.
no setter
currentThemeName String
Returns the name of the currently active theme.
no setter
instance Themed
Returns the singleton instance of Themed.
no setter
isCustomTheme bool
Returns true if the currently active theme is a custom theme.
no setter
isDarkMode bool
Returns true if the currently active theme is the built-in dark theme.
no setter
isLightMode bool
Returns true if the currently active theme is the built-in light theme.
no setter

Static Methods

clearCustomThemes() → void
Removes all custom themes, keeping only 'light' and 'dark'.
createTheme({required String name, required Color primaryColor, required Color secondaryColor, required Brightness brightness, Color? backgroundColor, Color? surfaceColor, Color? scaffoldBackgroundColor, Color? appBarColor, Color? cardColor, Color? dividerColor, Color? iconColor, Color? textColor, Color? hintColor, Color? disabledColor, Color? errorColor, Color? buttonColor, double? borderRadius, double? elevation, Color? fabColor, Color? inputFillColor, Color? inputBorderColor, String? fontFamily, FontWeight? fontWeight, TextStyle? headlineStyle, TextStyle? bodyStyle, TextStyle? buttonTextStyle, bool? useMaterial3, bool? useRippleEffect}) → void
Creates a custom theme with the specified configuration.
hasTheme(String name) bool
Checks if a theme with the given name exists.
initialize({ThemeStorageAdapter? storageAdapter}) Future<void>
Initializes Themed with optional persistent storage.
isActiveCustomTheme(String name) bool
Returns true if the custom theme with the given name is currently active.
removeTheme(String name) → void
Removes a custom theme.
setTheme(String name) → void
Switches to the theme with the specified name.
toggleTheme() → void
Toggles between the built-in light and dark themes.