span method

  1. @override
InlineSpan span(
  1. BuildContext context,
  2. String text,
  3. TextStyle? style,
  4. TextDirection textDirection,
  5. void onLinkTab(
    1. String url,
    2. String title
    )?,
)
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,
        ),
      ),
    ),
  );
}