didChangeLocales method

  1. @protected
  2. @mustCallSuper
  3. @override
void didChangeLocales(
  1. List<Locale>? locales
)
override

Called when the system tells the app that the user's locale has changed. For example, if the user changes the system language settings.

Implementation

@protected
@mustCallSuper
@override
void didChangeLocales(List<Locale>? locales) {
  // A triggered system event
  _hadSystemEvent = true;

  ///
  /// This method exposes notifications from [Window.onLocaleChanged].

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

  for (final listener in _beforeList) {
    listener.didChangeLocales(locales);
  }
  for (final con in _controllerList) {
    con.didChangeLocales(locales);
  }
  for (final listener in _afterList) {
    listener.didChangeLocales(locales);
  }

  _setStateAllowed = true;

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