fluentSpansToInline function

List<InlineSpan> fluentSpansToInline(
  1. List<FluentSpan> spans, {
  2. Map<String, FluentTagBuilder> tags = const {},
  3. Map<String, TextStyle> styles = const {},
  4. void onUnknownTag(
    1. FluentMarkupSpan node
    )?,
})

Convert a resolved fluent span tree to Flutter InlineSpans — Mozilla's overlay model meeting Text.rich.

Per markup tag, in precedence order:

  1. a tags builder — full power: WidgetSpans, tap recognizers from node.attrs, nested styling;
  2. a styles entry — the tag's children wrapped in a styled TextSpan, the 90% case;
  3. neither — the OVERLAY RULE: the tag's children render unstyled (translator content is never dropped), and onUnknownTag fires. Leaving onUnknownTag null 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),
    },
];