dispatchLocalesChanged method

  1. @protected
  2. @mustCallSuper
void dispatchLocalesChanged(
  1. List<Locale>? locales
)

Notify all the observers that the locale has changed (using WidgetsBindingObserver.didChangeLocales), giving them the locales argument.

This is called by handleLocaleChanged when the PlatformDispatcher.onLocaleChanged notification is received.

Implementation

@protected
@mustCallSuper
void dispatchLocalesChanged(List<Locale>? locales) {
  for (final observer in List<WidgetsBindingObserver>.of(_observers)) {
    try {
      observer.didChangeLocales(locales);
    } catch (exception, stack) {
      FlutterError.reportError(
        FlutterErrorDetails(
          exception: exception,
          stack: stack,
          library: 'widgets library',
          context: ErrorDescription(
            'while dispatching notifications for WidgetsBindingObserver.didChangeLocales',
          ),
        ),
      );
    }
  }
}