Norbert515 / dynamic_theme

Dynamically changing your theme without hassle
MIT License
322 stars 68 forks source link

Maintaining theme after close #26

Open DanielSmith1239 opened 5 years ago

DanielSmith1239 commented 5 years ago

Hello, I'm confused about how we're supposed to maintain the theme after the app is closed. Right now, here is my code for creating the app:

return DynamicTheme(
  defaultBrightness: Brightness.light,
  data: (brightness) => DynamicTheme.of(context)?.data ?? Themes.light.getThemeData(context),
  themedWidgetBuilder: (context, theme) {
    return MaterialApp(
      theme: theme,
      debugShowCheckedModeBanner: false,
      title: 'Is It Raining?',
      home: DataContainerView()
    );
  }
);

This doesn't seem to be working for me. DynamicTheme.of(context) always returns null.

Norbert515 commented 5 years ago

Dynamic Theme only persists the brightness.

data: (brightness) => ...

contains the brightness which you can use. There you can construct your usual theme using that brightness.