didChangePlatformBrightness method

  1. @override
  2. @mustCallSuper
void didChangePlatformBrightness()
inherited

Called when the platform brightness changes.

Implementation

@override
@mustCallSuper
void didChangePlatformBrightness() {
  // A triggered system event
  _hadSystemEvent = true;

  // Don't if the State object is defunct.
  if (!mounted) {
    return;
  }

  /// No 'setState()' functions are allowed to fully function at this point.
  _setStateAllowed = false;

  for (final con in controllerList) {
    con.didChangePlatformBrightness();
  }

  _setStateAllowed = true;

  if (_setStateRequested) {
    _setStateRequested = false;
    // Only the latest State is rebuilt
    if (isLastState) {
      /// Perform a 'rebuild' if requested.
      setState(() {});
    }
  }

  // Record the triggered event
  assert(() {
    if (_printEvents) {
      debugPrint(
          '============ Event: didChangePlatformBrightness() in $this');
    }
    return true;
  }());
}