Norbert515 / dynamic_theme

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

How can I use it with Switch button/checkbox #29

Closed ABINASH56 closed 5 years ago

ABINASH56 commented 5 years ago

I want to enable light/dark mode through switch/checkbox instead of button ..How can I achieve this? Please help

Khaoz-Topsy commented 5 years ago

You could do this:

  Checkbox(
    value: DynamicTheme.of(context).brightness == Brightness.light,
    onChanged: (bool isLight) => DynamicTheme.of(context).setBrightness(isLight? Brightness.light : Brightness.dark),
  );

Maybe Norbert515 has a better solution 😋

ABINASH56 commented 5 years ago

Norbert is not replying to anyone.Thank you for your help. Your answer was helpful

Norbert515 commented 5 years ago

Sorry for my absence - @Khaoz-Topsy answer is great. Additionally, a PR just landed which makes toggling the brightness easier.