defaultSpan method
Exactly what a link renders as when no builder is given.
Returning this from InlineLinkBuilder is a no-op, which makes it the safe starting point: keep it, then change one thing.
style replaces the style on the container span. It does not
restyle the label, because labelSpans were already built with their own
styles — bold inside a link stays bold, and a colour set here does not
reach them. To recolour the label, rebuild it and pass children:
inlineLinkBuilder: (link) => link.defaultSpan(
children: [TextSpan(text: link.label, style: link.style.copyWith(
color: link.url.startsWith('https://') ? null : Colors.orange,
))],
),
For a widget instead of a span, see asWidgetSpan.
Implementation
InlineSpan defaultSpan({TextStyle? style, List<InlineSpan>? children}) {
return LinkTextSpan.wrapping(
children: children ?? labelSpans,
url: url,
linkStyle: linkStyle,
style: style ?? this.style,
hoverStyle: hoverStyle,
onTap: onTap,
);
}