span method
InlineSpan
span(
- BuildContext context,
- String text,
- TextStyle? style,
- TextDirection textDirection,
- void onLinkTab()?,
override
Implementation
@override
InlineSpan span(
BuildContext context,
String text,
TextStyle? style,
TextDirection textDirection,
final void Function(String url, String title)? onLinkTab,
) {
var match = exp.firstMatch(text.trim());
if (match?[1] == null && match?[2] == null) {
return const TextSpan();
}
return WidgetSpan(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: GestureDetector(
onTap: () {
if (onLinkTab == null) {
return;
}
onLinkTab("${match?[2]}", "${match?[1]}");
},
child: TexText(
"${match?[1]}",
textDirection: textDirection,
style: (style ?? const TextStyle()).copyWith(
color: Colors.blueAccent,
decorationColor: Colors.blue,
decoration: TextDecoration.underline,
),
),
),
);
}