fluentSpansToInline function
List<InlineSpan>
fluentSpansToInline(
- List<
FluentSpan> spans, { - Map<
String, FluentTagBuilder> tags = const {}, - Map<
String, TextStyle> styles = const {}, - void onUnknownTag(
- FluentMarkupSpan node
Convert a resolved fluent span tree to Flutter InlineSpans —
Mozilla's overlay model meeting Text.rich.
Per markup tag, in precedence order:
- a
tagsbuilder — full power:WidgetSpans, tap recognizers fromnode.attrs, nested styling; - a
stylesentry — the tag's children wrapped in a styled TextSpan, the 90% case; - neither — the OVERLAY RULE: the tag's children render unstyled
(translator content is never dropped), and
onUnknownTagfires. LeavingonUnknownTagnull asserts in debug builds so a translator's typo'd tag is loud in dev and harmless in release; pass a callback (even an empty one) to opt out.
Implementation
List<InlineSpan> fluentSpansToInline(
List<FluentSpan> spans, {
Map<String, FluentTagBuilder> tags = const {},
Map<String, TextStyle> styles = const {},
void Function(FluentMarkupSpan node)? onUnknownTag,
}) => [
for (final span in spans)
switch (span) {
FluentTextSpan(:final text) => TextSpan(text: text),
FluentMarkupSpan() => _markup(span, tags, styles, onUnknownTag),
},
];