setLocale method

E setLocale(
  1. E locale, {
  2. bool? listenToDeviceLocale = false,
})

Sets locale. Returns the locale which has been set.

Locale gets changed automatically if listenToDeviceLocale is true and TranslationProvider is used. If null, then the last state is used. By default, calling this method disables the listener.

Implementation

E setLocale(E locale, {bool? listenToDeviceLocale = false}) {
  GlobalLocaleState.instance.setLocale(locale);
  updateProviderState(locale);
  if (listenToDeviceLocale != null) {
    this.listenToDeviceLocale = listenToDeviceLocale;
  }
  return locale;
}