span method

  1. @override
InlineSpan span(
  1. BuildContext context,
  2. String text,
  3. GptMarkdownConfig config
)
override

Implementation

@override
InlineSpan span(
  BuildContext context,
  String text,
  final GptMarkdownConfig config,
) {
  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: () {
        config.onLinkTab?.call("${match?[2]}", "${match?[1]}");
      },
      child: config.getRich(
        TextSpan(
          text: "${match?[1]}",
          style: (config.style ?? const TextStyle()).copyWith(
            color: Colors.blueAccent,
            decorationColor: Colors.blue,
            decoration: TextDecoration.underline,
          ),
        ),
      ),
    ),
  );
}