Skip to content
Talk to an engineerRequest access

Text formatting

Bold, italic, strikethrough, underline, highlight, subscript and superscript.

Bold, italic, strikethrough, underline and bold italic text, then a highlighted phrase, H₂O and s²

Markdown HTML Renders
**bold**, __bold__ <b>, <strong> bold
*italic*, _italic_ <i>, <em> italic
~~strike~~ <s>, <del> strikethrough
<u>, <ins> underline
<mark> highlighted (HighlightStyle)
<sub>, <sup> subscript, superscript (ScriptStyle)

An underscore inside a word is never emphasis, so snake_case_name stays as written; and * or _ followed by a space opens nothing, so 2 * 3 * 4 is arithmetic. See Markdown syntax for the rest of the rules.

Bold, italic, strikethrough and underline follow the surrounding text style and have no style object of their own.

How highlighted text — <mark> — is drawn.

Set it as GptMarkdownStyleSheet(highlight: HighlightStyle(…)) on the widget, or in GptMarkdownThemeData for the whole app. Every field is optional; an unset one falls back to the theme, then to the default.

Field Type Description
backgroundColor Color? The colour behind the text.
color Color? The text colour. Defaults to the colour that reads on backgroundColor’s default.
Member Type Description
merge(HighlightStyle? other) HighlightStyle This style, with any unset field taken from other, field by field.
resolve(ColorScheme scheme) HighlightStyle This style with every remaining default filled in from scheme.
copyWith({Color? backgroundColor, Color? color}) HighlightStyle A copy with the given fields replaced.
static lerp(HighlightStyle? a, HighlightStyle? b, double t) HighlightStyle? Linearly interpolates between two styles.

How superscript and subscript text — <sup>, <sub> — is drawn.

Set it as GptMarkdownStyleSheet(script: ScriptStyle(…)) on the widget, or in GptMarkdownThemeData for the whole app. Every field is optional; an unset one falls back to the theme, then to the default.

Field Type Description
scale double? The text’s size as a fraction of the surrounding text. Defaults to 0.75.
color Color? The text colour. Defaults to the surrounding text’s.
Member Type Description
static defaultScale = 0.75 double The default scale.
merge(ScriptStyle? other) ScriptStyle This style, with any unset field taken from other, field by field.
copyWith({double? scale, Color? color}) ScriptStyle A copy with the given fields replaced.
static lerp(ScriptStyle? a, ScriptStyle? b, double t) ScriptStyle? Linearly interpolates between two styles.