isSupported method

  1. @override
bool isSupported(
  1. Locale locale
)
override

Whether resources for the given locale can be loaded by this delegate.

Return true if the instance of T loaded by this delegate's load method supports the given locale's language.

Implementation

@override
bool isSupported(Locale locale) {
  final _locales = I10n._locales;
  // If 'I10n._locale == null' then you're loading the app's locale.
  if (I10n._locale == null) {
    I10n._locale = locale;

    if (_locales == null || _locales.isEmpty) {
      I10n._locales = [locale.toLanguageTag()];
    } else if (!_locales.contains(locale.toLanguageTag())) {
      _locales.add(locale.languageCode);
      I10n._locales = _locales;
    }
    _locale ??= locale;
  }
  return _locales?.contains(locale.toLanguageTag()) ?? false;
}