Default components / Links & media
Autolink
Turns bare URLs, www hosts, email addresses, and angle-bracket URLs into links.
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
1Visit https://gptmarkdown.com or mail hello@example.com.Default behavior
Runtime behavior
Bare http, https, mailto, and xmpp links work by default. Set autolink: false to leave bare values as text.
Accessibility note
An autolink shares the same app-owned link handler as a Markdown link.
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 autolinkSchemes: {'tel'},
4 styleSheet: const GptMarkdownStyleSheet(
5 link: LinkStyle(decoration: TextDecoration.none),
6 ),
7 onLinkTap: (url, title) => launchUrlString(url),
8)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)
This is the same callback used by Markdown links.
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 MyAutolinkMdOverride(),
7 ...MarkdownComponent.inlineComponents,
8 ],
9)