richContext<T> static method
TextSpan?
richContext<T>(
- TranslationMetadata<
BaseAppLocale, BaseTranslations> meta, - String path,
- Map<
String, Object> param
Handler for overridden rich context.
Returns a TextSpan if the path was successfully overridden.
Returns null otherwise.
Implementation
static TextSpan? richContext<T>(
TranslationMetadata meta, String path, Map<String, Object> param) {
final node = meta.overrides[path];
if (node == null) {
return null;
}
if (node is! ContextNode) {
print('Overridden $path is not a ContextNode but a ${node.runtimeType}.');
return null;
}
if (!node.rich) {
print('Overridden $path must be rich (RichText).');
return null;
}
final context = param[node.paramName]! as Enum;
return (node.entries[context.name]! as RichTextNode?)
?._buildTextSpan<T>(meta, param, node.paramName);
}