build method

  1. @override
InlineSpan build()
override

Implementation

@override
InlineSpan build() {
  final content = attributes['content'] ?? '';
  final isInline = attributes['isInline'] == 'true';
  final style = parentStyle ?? config.p.textStyle;
  if (content.isEmpty) return TextSpan(style: style, text: textContent);
  final latex = Math.tex(
    content,
    mathStyle: MathStyle.text,
    textStyle: textStyle,
    textScaleFactor: 1,
    onErrorFallback: (error) {
      return Text(
        textContent,
        style: style.copyWith(color: Colors.red),
      );
    },
  );
  return WidgetSpan(
      child: !isInline
          ? Container(
              width: double.infinity,
              margin: const EdgeInsets.symmetric(vertical: 16),
              child: Center(child: latex),
            )
          : latex);
}