handlePlatformBrightnessChanged method

  1. @override
void handlePlatformBrightnessChanged ()
override

{@template on_platform_brightness_change} Called when the platform brightness changes.

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

Sample Code

Querying Window.platformBrightness:

final Brightness brightness = WidgetsBinding.instance.window.platformBrightness;

Querying MediaQuery directly:

final Brightness brightness = MediaQuery.platformBrightnessOf(context);

Querying MediaQueryData:

final MediaQueryData mediaQueryData = MediaQuery.of(context);
final Brightness brightness = mediaQueryData.platformBrightness;

See Window.onPlatformBrightnessChanged. {@endtemplate}

Implementation

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