verifiedLocale function

String? verifiedLocale(
  1. String? newLocale,
  2. bool localeExists(
    1. String
    )
)

Implementation

String? verifiedLocale(String? newLocale, bool Function(String) localeExists) {
  if (newLocale == null) {
    return verifiedLocale(Intl.getCurrentLocale(), localeExists);
  }
  if (localeExists(newLocale)) {
    return newLocale;
  }
  for (final each in [
    canonicalizedLocale(newLocale),
    shortLocale(newLocale),
    'fallback',
  ]) {
    if (localeExists(each)) {
      return each;
    }
  }

  return newLocale;
}