InjectedTheme<KEY> class abstract mixin

Injection of a state that handle app theme switching.

This injected state abstracts the best practices of the clean architecture to come out with a simple, clean, and testable approach to manage app theming.

The approach consists of the following steps:

  • Instantiate an InjectedTheme object using RM.injectTheme method.
  • we use the TopAppWidget that must be on top of the MaterialApp widget.
     void main() {
       runApp(MyApp());
     }
    
     class MyApp extends StatelessWidget {
       // This widget is the root of your application.
       @override
       Widget build(BuildContext context) {
         return TopAppWidget(//Use TopAppWidget
           injectedTheme: themeRM, //Set te injectedTheme
           builder: (context) {
             return MaterialApp(
               theme: themeRM.lightTheme, //light theme
               darkTheme: themeRM.darkTheme, //dark theme
               themeMode: themeRM.themeMode, //theme mode
               home: HomePage(),
             );
           },
         );
       }
     }
    
Implementers

Constructors

InjectedTheme()

Properties

darkTheme → ThemeData?
Get the current dark theme.
no setter
hashCode int
The hash code for this object.
no setterinherited
isDarkTheme bool
Wether the current mode is dark.
no setter
lightTheme → ThemeData
Get the current light theme.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state ↔ KEY
The current state (theme name)
getter/setter pair
supportedDarkThemes Map<KEY, ThemeData>
Get supported dark themes
no setter
supportedLightThemes Map<KEY, ThemeData>
Get supported light themes
no setter
themeMode ↔ ThemeMode
The current ThemeMode
getter/setter pair

Methods

activeTheme([KEY? themeName]) → ThemeData
Get the active ThemeData depending on ThemeMode.
dispose() → void
Dispose the state
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toggle() → void
Toggle the ThemeMode between light and dark mode
toString() String
A string representation of this object.
inherited

Operators

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