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());
  var content = match?[1];
  if (content == null) {
    return const TextSpan();
  }
  return WidgetSpan(
    alignment: PlaceholderAlignment.middle,
    // baseline: TextBaseline.alphabetic,
    child: Padding(
      padding: const EdgeInsets.all(2),
      child: config.sourceTagBuilder
              ?.call(context, content, const TextStyle()) ??
          SizedBox(
            width: 20,
            height: 20,
            child: Material(
              color: Theme.of(context).colorScheme.onInverseSurface,
              shape: const OvalBorder(),
              child: FittedBox(
                fit: BoxFit.scaleDown,
                child: Text(
                  content,
                  // style: (style ?? const TextStyle()).copyWith(),
                  textDirection: config.textDirection,
                ),
              ),
            ),
          ),
    ),
  );
}