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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] onChangeTheme method #86

Closed
YehudaKremer opened this issue Mar 6, 2022 · 10 comments
Closed

[Feature Request] onChangeTheme method #86

YehudaKremer opened this issue Mar 6, 2022 · 10 comments

Comments

@YehudaKremer
Copy link

YehudaKremer commented Mar 6, 2022

Hello, thank you for this useful package.

Is it possible to add an event method that fire when the windows theme is changed:

  1. dark mode activated/turn off
  2. color theme changed

Anyway, thanks again! 馃憤

@lijy91
Copy link
Member

lijy91 commented Mar 6, 2022

I added the setBrightness method, which can toggle between light/dark mode.

QQ20220306-160841-HD.mp4

@YehudaKremer
Copy link
Author

Thanks for the super quick response and the nice toggle function (i will use it) 馃憤

But I meant that when the user goes to windows settings and manually change the system theme mode or theme color,
then the function onChangeTheme will fire up so my app will know that is time to use: await SystemTheme.accentInstance.load();

Sorry if I was not clear enough 馃槗

@lijy91
Copy link
Member

lijy91 commented Mar 6, 2022

@YehudaKremer

The flutter engine supports monitoring theme changes, you just need to call setBrightness there.

  1. Detect the dark mode using, WidgetsBinding.instance?.window.platformBrightness
  2. You may also have to listen for the brightness changes from the system in order to update in real-time using WidgetsBindingObserver, and overriding, didChangePlatformBrightness();

Currently in windows this must be added https://github.com/flutter/flutter/pull/88520/files

https://stackoverflow.com/a/62607827

@lijy91
Copy link
Member

lijy91 commented Mar 6, 2022

QQ.20220306170813_Trim.mp4

@lijy91
Copy link
Member

lijy91 commented Mar 6, 2022

Supported, will be released in the next version

@lijy91 lijy91 closed this as completed Mar 6, 2022
@YehudaKremer
Copy link
Author

Thank you! I didn't know that.

Theme Mode change detection, worked only after I added what you quote:

Currently in windows this must be added https://github.com/flutter/flutter/pull/88520/files

Very cool!

The only extra thing that I don't know if it's covered by Flutter for windows,
is the change detection of theme color (not the theme mode),

Do you know anything about that?
Video-detail-page

@lijy91
Copy link
Member

lijy91 commented Mar 6, 2022

Unfortunately, it cannot detect custom themes, I don't find a solution right now.

@YehudaKremer
Copy link
Author

I guess it's early days for flutter-windows...

Thanks again for your help (6eb721c) and knowledge share (#86 (comment)) 馃憤

@lijy91
Copy link
Member

lijy91 commented Mar 6, 2022

By the way, you can use system_theme to get the system accent color.

@YehudaKremer
Copy link
Author

Already using it, works well 馃憤

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