Default components / Links & media
Markdown link
Renders a labeled Markdown link and delegates destination handling to your app.
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
1Read the [package guide](https://pub.dev/packages/gpt_markdown).Default behavior
Runtime behavior
Balanced parentheses in a URL are supported. The package intentionally does not launch URLs itself.
Accessibility note
Use a descriptive label; wire onLinkTap to an accessible navigation or confirmation flow.
Theming & styling
Theme layering guideLinkStyle 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 |
|---|---|
| LinkStyle | color · hoverColor · decoration · decorationThickness · fontWeight |
1GptMarkdown(
2 markdown,
3 styleSheet: const GptMarkdownStyleSheet(
4 link: LinkStyle(
5 color: Color(0xFF0B57D0),
6 decoration: TextDecoration.none,
7 fontWeight: FontWeight.w600,
8 ),
9 ),
10 onLinkTap: (url, title) => launchUrlString(url),
11)App-wide or scoped theme
1GptMarkdownThemeData(
2 brightness: Brightness.light,
3 styleSheet: const GptMarkdownStyleSheet(
4 link: LinkStyle(
5 // Set only the values your app needs.
6 ),
7 ),
8)Builders & callbacks
linkBuilder
Widget Function(BuildContext context, InlineSpan label, String url, TextStyle style)
Use this only when the default widget structure is no longer the right shape. The resolved style or configuration is passed where applicable.
onLinkTap
void Function(String url, String title)
The callback is intentionally app-owned; add url_launcher in your app if you need external navigation.
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 MyATagMdOverride(),
7 ...MarkdownComponent.inlineComponents,
8 ],
9)