Default components / Code & math
Inline LaTeX
Renders an inline TeX expression within surrounding prose.
What it renders
Live Flutter preview
Starting the Flutter widget
Rendering this component with gpt_markdown…
This is the real GptMarkdown Flutter widget, rendered with the exact Markdown input shown here.
Markdown input
1The area is \(\pi r^2\).Default behavior
Runtime behavior
The component matches \( ... \). Dollar-sign syntax is enabled separately with useDollarSignsForLatex.
Accessibility note
Inline math is a widget span; avoid packing long expressions into link labels.
Theming & styling
Theme layering guideLatexStyle is the component's appearance surface. Set only the values you need; style-sheet values merge field-by-field with the active theme and package defaults.
| Style class | Available fields |
|---|---|
| LatexStyle | textStyle · padding · backgroundColor · borderRadius · scrollBlockHorizontally |
1GptMarkdown(
2 markdown,
3 useDollarSignsForLatex: true,
4 styleSheet: const GptMarkdownStyleSheet(
5 latex: LatexStyle(backgroundColor: Color(0x08000000)),
6 ),
7)App-wide or scoped theme
1GptMarkdownThemeData(
2 brightness: Brightness.light,
3 styleSheet: const GptMarkdownStyleSheet(
4 latex: LatexStyle(
5 // Set only the values your app needs.
6 ),
7 ),
8)Builders & callbacks
latexBuilder
Widget Function(BuildContext context, String tex, TextStyle textStyle, bool inline)
Use this only when the default widget structure is no longer the right shape. The resolved style or configuration is passed where applicable.
Safely override the default
A custom component list replaces a default list entirely. Put your matching component first, then append the package defaults so every other Markdown feature continues to render.
1// Passing inlineComponents replaces its defaults. Prepend to override matching syntax,
2// then keep every built-in component after it.
3GptMarkdown(
4 markdown,
5 inlineComponents: [
6 MyLatexMathOverride(),
7 ...MarkdownComponent.inlineComponents,
8 ],
9)