tOrNull method
Attempts to retrieve a translation at key
.
Returns null
if the translation cannot be found.
See also: t for a function that returns a non-nullable String
Implementation
String? tOrNull(
String key, {
Locale? locale,
String? context,
int? count,
Map<String, dynamic>? variables,
I18NextOptions? options,
}) {
variables ??= {};
if (context != null) variables['context'] = context;
if (count != null) variables['count'] = count;
locale ??= this.locale;
final newOptions = this.options.merge(options);
var result = Translator(pluralResolver, resourceStore)
.call(key, locale, variables, newOptions);
if (result == null && newOptions.missingKeyHandler != null) {
result =
newOptions.missingKeyHandler!(locale, key, variables, newOptions);
}
return result;
}