kdsuneraavinash / theme_provider

Easy to use, customizable and pluggable Theme Provider.
https://pub.dartlang.org/packages/theme_provider
MIT License
152 stars 28 forks source link

Dark mode #2

Closed chentao0707 closed 4 years ago

chentao0707 commented 4 years ago

How to adapt the Dark Mode?

hectorAguero commented 4 years ago

From what I understand, you just need to add another custom theme in themes[] like the example, but with the value: Brigthness.dark in brigthness property, so for example:


class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ThemeProvider(
      themes: [
        AppTheme(
          id: "light_theme", // Id(or name) of the theme(Has to be unique)
          data: ThemeData(  // Real theme data
            brightness: Brightness.light,
            primaryColor: Colors.teal,
            accentColor: Colors.red,
          ),
        ),
        AppTheme(
          id: "dark_theme", // Id(or name) of the theme(Has to be unique)
          data: ThemeData(  // Real theme data
            brightness: Brightness.dark,
            primaryColor: Colors.teal,
            accentColor: Colors.red,
          ),
        ),
      ],
      ],
      child: MaterialApp(
        home: ThemeConsumer(
          child: HomePage(),
        ),
      ),
    );
  }
}
kdsuneraavinash commented 4 years ago

@chentao0707 Do you mean the functionality when the user changes the system theme to dark mode?

chentao0707 commented 4 years ago

Yes. I hope ThemeProvider can change the dark theme Automatically when the user changed the system theme to dark mode.