handlePlatformBrightnessChanged method

  1. @override
void handlePlatformBrightnessChanged ()
override

Called when the platform brightness changes.

The current platform brightness can be queried either from a Flutter binding, or from a MediaQuery widget.

{@inject-html}

{@end-inject-html}Querying [Window.platformBrightness].{@inject-html}
final Brightness brightness = WidgetsBinding.instance.window.platformBrightness;
{@end-inject-html}

{@inject-html}

{@end-inject-html}Querying [MediaQuery] directly.{@inject-html}
final Brightness brightness = MediaQuery.platformBrightnessOf(context);
{@end-inject-html}

{@inject-html}

{@end-inject-html}Querying [MediaQueryData].{@inject-html}
final MediaQueryData mediaQueryData = MediaQuery.of(context);
final Brightness brightness = mediaQueryData.platformBrightness;
{@end-inject-html}

See Window.onPlatformBrightnessChanged.

Implementation

@override
void handlePlatformBrightnessChanged() {
  super.handlePlatformBrightnessChanged();
  for (WidgetsBindingObserver observer in _observers)
    observer.didChangePlatformBrightness();
}