find method

Finds the resource with locale.

Implementation

FutureOr<IntlResourceContent?> find(String locale) {
  if (locale.isEmpty) return null;

  var cached = _findCache[locale];
  if (cached != null) return cached;

  return _getLanguagesCodesToLookup().resolveMapped((languagesToLookup) {
    if (!languagesToLookup.contains(locale)) return null;

    var finding = _finding[locale];
    if (finding != null) return finding;

    _finding[locale] = finding = _findImpl(locale);

    finding.then((_) {
      _finding.remove(locale);
    });

    return finding;
  });
}