handlePlatformBrightnessChanged method

  1. @override
void handlePlatformBrightnessChanged()
override

Called when the platform brightness changes.

The current platform brightness can be queried from a Flutter binding or from a MediaQuery widget. The latter is preferred from widgets because it causes the widget to be automatically rebuilt when the brightness changes.

{@tool snippet} Querying MediaQuery.platformBrightnessOf directly. Preferred.

final Brightness brightness = MediaQuery.platformBrightnessOf(context);

{@end-tool}

{@tool snippet} Querying PlatformDispatcher.platformBrightness.

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

{@end-tool}

See dart:ui.PlatformDispatcher.onPlatformBrightnessChanged.

Implementation

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