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

can not get windows dark -> light switch, but macOS is OK #37

Open
lucasjinreal opened this issue Oct 6, 2022 · 7 comments
Open

can not get windows dark -> light switch, but macOS is OK #37

lucasjinreal opened this issue Oct 6, 2022 · 7 comments

Comments

@lucasjinreal
Copy link

Hi, I have a same logic like this:

if (brightness == InterfaceBrightness.dark) {
                            brightness = InterfaceBrightness.light;
                          } else if (brightness == InterfaceBrightness.light) {
                            brightness = InterfaceBrightness.dark;
                          } else {
                            brightness = InterfaceBrightness.dark;
                          }
                          bool v = brightness == InterfaceBrightness.dark;
                          // aboutBloc.setForceDark(v);
                          if (v) {
                            Get.changeTheme(themeDataDark);
                          } else {
                            Get.changeTheme(themeData);
                          }
                          print('[brightness] crt brightness: ${brightness}');
                          this.setWindowEffect(WindowEffect.acrylic,
                              brightness == InterfaceBrightness.dark);

...

void setWindowEffect(WindowEffect value, bool dark) {
    Window.setEffect(
      effect: value,
      color: this.color,
      dark: dark,
    );
    if (Platform.isMacOS) {
      if (brightness != InterfaceBrightness.auto) {
        Window.overrideMacOSBrightness(
            dark: brightness == InterfaceBrightness.dark);
      }
    }
    this.setState(() => this.effect = value);
  }



the printed out brightness is dark and light when switch.

But the setWindowEffect can not make window to bright. While same code on macOS is ok.

what'sthe problem here?

@alexmercerind
Copy link
Owner

alexmercerind commented Oct 7, 2022

Hi @jinfagang,

The dark argument in Window.setEffect controls the "darkness" of the acrylic effect on Windows.
This is only applicable for Windows 11!

@alexmercerind
Copy link
Owner

For Windows 10 or lower, changing the value of passed color can tint your acrylic darker/lighter.
This API is made public/documented by Microsoft after Windows 11 release. Windows 10 still uses an old "hack".

@lucasjinreal
Copy link
Author

lucasjinreal commented Oct 7, 2022

@alexmercerind My windows verison exactly windows 11.

@alexmercerind
Copy link
Owner

Does the example app not work? What's your Windows 11 build number?

@lucasjinreal
Copy link
Author

@alexmercerind The code above should be identical to example (copied from there). Am on latest windows 11

@alexmercerind
Copy link
Owner

@lucasjinreal
Copy link
Author

@alexmercerind thank u, let me have a try.

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