Skip to main content

Themes

introduction​

modern apps must have light and dark theme at least , also might need more than one light/dark theme the ability and make users able to switch between themes with in the app not just stick to the OS choices , persist the chosen theme and use next the the app opens

all of that is ready and more features to boost the theming process

build your themes

at config/theme.dart add your brand themes

class AppThemeConfig extends ThemeConfig {

/// * List of available thames
/// you can add as many themes as you need there is no limit but at least must have one

List<QTheme> get themes => [
QTheme(
id: 'dark',
name: 'Dark',
theme: ThemeData.dark(),
),
QTheme(
id: 'light',
name: 'Light',
theme: ThemeData.light(),
),
];
}

boot the theme​

inside the launchers list do not forgot to add your config file to the Themes

add ThemeLauncher to app lunchers list and inside the constructor give it your config object

switch to the next theme​

AppTheme.next()

switch to specific theme by index​

AppTheme.updateTo(2)

get current theme​

/// without context
AppTheme.current

/// with context

Theme.of(context);


/// with readable package 😉
context.theme

get current theme index​

 AppTheme.currentIndex