findLocaleByCode method Null safety

Locale findLocaleByCode(
  1. String code
)

Find locale from supported list based on provided code. i.e. Locale ("en", "US") = "en_US"

Implementation

static Locale findLocaleByCode(String code) {
  for (Locale locale in supportedLocales)
    if (code == generateCode(locale)) return locale;
  return defaultLocale;
}