indexTranslationsIn<T extends Object> function
Read this widget's translated text off a property, for widgets that render a string their own way instead of handing it to a paragraph.
A markdown renderer parses the value and builds its own spans out of
substrings; a chart paints its labels with a TextPainter and no paragraph
exists at all. Either way the glyphs on screen are not the object the
catalog handed out — but the widget still holds that object in a
property, and reading it there is exact.
indexTranslationsIn<Markdown>((widget) => widget.data);
Declared once per widget type, in the test's flutter_test_config.dart
beside indexTranslations, and it then covers every use in the app. The
type is yours, so nothing here depends on the package that defines it.
Type it as whatever your code writes: the walk reads the widget summary
tree, so a Markdown your design system builds internally is not a node —
its wrapper, which you do write, is.
Fails closed like the rest. A property that is null, or holds a string no catalog minted, attributes nothing.
Registered for the process, not the scenario: TranslationIndex.reset runs between scenarios and leaves these alone.
Implementation
void indexTranslationsIn<T extends Object>(String? Function(T widget) text) =>
TranslationIndex.sources.add((widget) => widget is T ? text(widget) : null);