Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizing based on each brightness #25

Open
mohammadne opened this issue Sep 11, 2019 · 1 comment
Open

Customizing based on each brightness #25

mohammadne opened this issue Sep 11, 2019 · 1 comment

Comments

@mohammadne
Copy link

I want to define accentColor , scaffoldBackgroundColor , for each brightness.
also I have some textTheme which I want to define for each brightness.
but if I write scaffoldBackgroundColor like bellow , it doesn't work:

ThemeData(
                brightness: brightness,
                scaffoldBackgroundColor:
                    Theme.of(context).brightness == Brightness.light
                        ? Colors.black
                        : Colors.white,
               ...
                fontFamily: 'IranYekan',
                textTheme: TextTheme(
                  headline: TextStyle(
                      color: Colors.black54, fontWeight: FontWeight.w700),
                  title: TextStyle(
                      color: Colors.black54, fontWeight: FontWeight.w700),
                  subtitle: TextStyle(fontWeight: FontWeight.w700),
                  body2: TextStyle(fontWeight: FontWeight.w300),
                  display1: TextStyle(fontWeight: FontWeight.w700),
                  display2: TextStyle(fontWeight: FontWeight.w700),
                  display3: TextStyle(fontWeight: FontWeight.w700),
                  display4: TextStyle(fontWeight: FontWeight.w700),
                ),
              ...
              )

it seems that this themeData execute only once,
if I use DynamicTheme.of(context).setThemeData(Theme.of(context).copyWith());
also it raised an error
because I want to save last theme which user select and its accentColor and ... .
also I tried to define darkTheme in materialApp but it doesn't work.
if we had possibility to define brightness features , it was so good.
but is it possible?

@Norbert515
Copy link
Owner

Hey, sorry - I'm not quite sure what the issue is.

DynamicTheme.of(context).setThemeData(Theme.of(context).copyWith());

should work just fine.
Also, change Theme.of(context).brightness to brightness as the builder supplies a brightness.

This package automatically saves only the brightness of the shared preferences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants