Default components / Inline text

Inline code

Renders single-backtick code as a selectable, baseline-aligned code chip.

HighlightedTextinline componentInlineCodeStyleinlineCodeBuilder

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

input.md
1Pass `inlineCodeStyle` to customize a single renderer.

Default behavior

Runtime behavior

This is inline code, not a fenced code block. The modern builder returns InlineSpan to preserve wrapping and selection.

Accessibility note

Prefer the inlineCodeStyle or inlineCodeBuilder; the older highlightBuilder creates a WidgetSpan and is deprecated.

Theming & styling

Theme layering guide

InlineCodeStyle is the component's appearance surface. A widget-level inlineCodeStyle replaces the theme-level inline-code style, then unresolved fields use package defaults.

Style classAvailable fields
InlineCodeStylefontFamily · fontFamilyFallback · fontSizeFactor · fontWeight · color · backgroundColor · borderColor · borderWidth · borderRadius · padding · boxHeightStyle
inline-code_style.dart
1GptMarkdown( 2 markdown, 3 inlineCodeStyle: const InlineCodeStyle( 4 fontFamily: 'GeistMono', 5 backgroundColor: Color(0x14656D76), 6 borderRadius: Radius.circular(6), 7 padding: EdgeInsets.symmetric(horizontal: 5, vertical: 2), 8 ), 9 inlineCodeBuilder: (context, code, style, codeStyle) => CodeTextSpan( 10 text: code, style: style, codeStyle: codeStyle, 11 ), 12)

App-wide or scoped theme

theme.dart
1GptMarkdownThemeData( 2 brightness: Brightness.light, 3 inlineCode: const InlineCodeStyle( 4 fontFamily: 'GeistMono', 5 ), 6)

Builders & callbacks

inlineCodeBuilder

InlineSpan Function(BuildContext context, String code, TextStyle style, InlineCodeStyle codeStyle)

Use this only when the default widget structure is no longer the right shape. The resolved style or configuration is passed where applicable.

Full builder and callback signatures

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.

keep_defaults.dart
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 MyHighlightedTextOverride(), 7 ...MarkdownComponent.inlineComponents, 8 ], 9)
Custom component guide

Related components