localeResolutionCallback static method

Locale? localeResolutionCallback(
  1. Locale? locale,
  2. Iterable<Locale> supportedLocales
)

Callback for locale resolution

Implementation

static Locale? localeResolutionCallback(
    Locale? locale, Iterable<Locale> supportedLocales) {
  if (locale != null) {
    for (var supportedLocale in supportedLocales) {
      if (supportedLocale.languageCode == locale.languageCode) {
        if (locale.countryCode == null) {
          return supportedLocale;
        } else if (supportedLocale.countryCode == locale.countryCode) {
          return supportedLocale;
        }
      }
    }
  }
  return defaultLocale;
}