LocaleMatcher constructor

LocaleMatcher(
  1. Iterable<LanguageId> supportedLocales, {
  2. bool noDefaultLocale = false,
  3. LanguageId? defaultLocale,
  4. int? threshold,
  5. LanguageId? desiredForThreshold,
  6. LanguageId? supportedForThreshold,
})

Create a new LocaleMatcher with specified supportedLocales.

If a defaultLocale is specified this will be used as first locale to match and will also be returned if there are no matches.

If no defaultLocale is specified, then the first entry from supportedLocales will be used as default, unless noDefaultLocale is set to true. in the later case no default will be set and if there is no match and empty result will be returned.

If the threshold is set no results with distance higher then the threshold will be returned. The threshold can be in the range [0-100].

Alternatively the threshold can be set by providing the desiredForThreshold and supportedForThreshold locales. In this case the distance between these two locales +1 will be sued as threshold.

Implementation

factory LocaleMatcher(
  Iterable<LanguageId> supportedLocales, {
  bool noDefaultLocale = false,
  LanguageId? defaultLocale,
  int? threshold,
  LanguageId? desiredForThreshold,
  LanguageId? supportedForThreshold,
}) {
  return _constructLocaleMatcher(supportedLocales, noDefaultLocale,
      defaultLocale, threshold, desiredForThreshold, supportedForThreshold);
}