didChangeLocales method

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

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;

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

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

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

  for (final con in controllerList) {
    con.didChangeLocales(locales);
  }

  _setStateAllowed = true;

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