has method

  1. @override
bool has(
  1. String key, {
  2. String? locale,
  3. String? namespace,
})
override

Checks if a translation key exists.

  • key: The translation key.
  • locale: Locale to check; uses current if null.
  • namespace: Namespace to search in.
  • Returns: True if the key exists.

Implementation

@override
bool has(String key, {String? locale, String? namespace}) {
  final loc = locale ?? _currentLocale;
  final ns = namespace ?? '';
  return _getTranslation(key, loc, ns) != null ||
      _getTranslation(key, loc, '') != null ||
      (loc != _fallbackLocale &&
          (_getTranslation(key, _fallbackLocale, ns) != null ||
              _getTranslation(key, _fallbackLocale, '') != null));
}