Skip to content
Talk to an engineerRequest access

Blockquote

Quoted text, with nesting and Markdown inside.

A quote with a bar down its side, and a second quote nested inside it with bold text

> at the start of a line; >> nests. Everything inside is Markdown. A quote whose first line is [!NOTE] or another marker is an alert instead.

styleSheet: const GptMarkdownStyleSheet(
blockQuote: BlockQuoteStyle(
barWidth: 4,
barColor: Color(0xFF6366F1),
barRadius: Radius.circular(2),
backgroundColor: Color(0x0A6366F1),
padding: EdgeInsetsDirectional.only(start: 12, top: 8, bottom: 8),
margin: EdgeInsets.symmetric(vertical: 8),
textStyle: TextStyle(fontStyle: FontStyle.italic),
),
),

A background is only drawn when you ask for one — no extra widget in the tree otherwise.

A callout style with a builder:

GptMarkdown(
text,
blockQuoteBuilder: (context, content, style) => Card(
color: Theme.of(context).colorScheme.surfaceContainerHighest,
child: Padding(padding: const EdgeInsets.all(12), child: content),
),
)

How a blockquote is drawn.

Set it as GptMarkdownStyleSheet(blockQuote: BlockQuoteStyle(…)) 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
barWidth double? Thickness of the bar down the side. Defaults to 3.
barColor Color? Colour of the bar. Defaults to ColorScheme.onSurfaceVariant.
barRadius Radius? Rounding of the bar. Defaults to square corners.
backgroundColor Color? Fill behind the quote. Defaults to none.
padding EdgeInsetsGeometry? Space between the bar and the quoted content. Defaults to start: 8.
margin EdgeInsetsGeometry? Space around the whole quote. Defaults to vertical: 2.
textStyle TextStyle? Applied on top of the surrounding text style. Defaults to no change.
Member Type Description
merge(BlockQuoteStyle? other) BlockQuoteStyle This style, with any unset field taken from other.
resolve(ColorScheme scheme) BlockQuoteStyle This style with every remaining null filled in.
copyWith({…}) BlockQuoteStyle A copy with the given fields replaced.
static lerp(BlockQuoteStyle? a, BlockQuoteStyle? b, double t) BlockQuoteStyle? Linearly interpolates between two blockquote styles.
merge: more

Per field, not per object: a style setting only barWidth keeps other’s colour and padding.

resolve: more

The defaults are the values the package used before blockquotes were configurable, so an app that sets nothing sees no change.

Replaces the whole blockquote widget.

Reach for styleSheet first — it covers the bar, padding, background and text style without giving up the default structure.

typedef BlockQuoteBuilder = Widget Function(
BuildContext context,
Widget content,
BlockQuoteStyle style,
);