Default components / Data & citations
Source tag
Renders numeric citation tags as compact, tappable source chips.
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 model cites its source [1].Default behavior
Runtime behavior
The chip receives the content inside the brackets and is rendered as an inline widget span.
Accessibility note
Use the callback to expose the source or an accessible explanation of what the citation opens.
Theming & styling
Theme layering guideSourceTagStyle 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 |
|---|---|
| SourceTagStyle | size · backgroundColor · shape · textStyle · padding |
1GptMarkdown(
2 markdown,
3 styleSheet: const GptMarkdownStyleSheet(
4 sourceTag: SourceTagStyle(
5 backgroundColor: Color(0xFFE8DEF8),
6 textStyle: TextStyle(fontSize: 11, fontWeight: FontWeight.w700),
7 ),
8 ),
9 onSourceTagTap: (content) => showSource(content),
10)App-wide or scoped theme
1GptMarkdownThemeData(
2 brightness: Brightness.light,
3 styleSheet: const GptMarkdownStyleSheet(
4 sourceTag: SourceTagStyle(
5 // Set only the values your app needs.
6 ),
7 ),
8)Builders & callbacks
sourceTagBuilder
Widget Function(BuildContext context, String content, TextStyle textStyle)
Use this only when the default widget structure is no longer the right shape. The resolved style or configuration is passed where applicable.
onSourceTagTap
void Function(String content)
The callback receives the text inside [brackets].
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 MySourceTagOverride(),
7 ...MarkdownComponent.inlineComponents,
8 ],
9)