IntlStrings constructor

IntlStrings(
  1. List<IntlString> values, {
  2. Locale? defaultLocale,
  3. Locale currentLocaleFunction()?,
  4. Locale? fallbackLocale,
})

Constructor

Notes:

  • If locale is not set or is null, currentLocaleFunction will be used.
  • If currentLocaleFunction is not null, it will be called to get the current locale.
  • If Locale is set, it will be used and currentLocaleFunction will be ignored.

Implementation

IntlStrings(
  List<IntlString> values, {
  Locale? defaultLocale,
  Locale Function()? currentLocaleFunction,
  Locale? fallbackLocale,
}) : _strings = Map.fromEntries(values.map((s) => MapEntry(s.locale, s))),
     defaultLocale =
         defaultLocale ??
         (currentLocaleFunction != null
             ? currentLocaleFunction()
             : getCurrentLocale()),
     fallbackLocale =
         fallbackLocale ?? Locale.fromSubtags(languageCode: 'en');