setLocale static method

bool setLocale(
  1. Locale? locale
)

Explicitly set a supported Locale using this class Set the Locale to translate Returns true if set to that Locale

Implementation

static bool setLocale(Locale? locale) {
  final set = locale != null &&
      // If there's translations, it must be found among them.
      (_localesSupported.isEmpty || _localesSupported.contains(locale));
  if (set) {
    if (_appLocale == null) {
      _appLocale = locale;
    } else {
      if (locale != _appLocale) {
        // Important to reset to false to find any new translations.
        _localeSet = false;
        _appLocale = locale;
      }
      // else, if they're the same, don't change anything.
    }
  }
  return set;
}