trySetLocale static method

void trySetLocale(
  1. String langCode, {
  2. IfLocaleNotFound ifLocaleNotFound = IfLocaleNotFound.doNothing,
})

Try to set Locale by string in LocaleSwitcher.supportedLocaleNames.

Just wrapper around: tryFindLocale and LocaleSwitcher.current = newValue;

If not found, will do one of IfLocaleNotFound.

Implementation

static void trySetLocale(String langCode,
    {IfLocaleNotFound ifLocaleNotFound = IfLocaleNotFound.doNothing}) {
  var loc = tryFindLocale(langCode, ifLocaleNotFound: ifLocaleNotFound);
  if (loc != null) {
    LocaleSwitcher.current = loc;
  }
}