Skip to content
Talk to an engineerRequest access

Lists

Bulleted and numbered lists, nested to any depth.

A bulleted list with a nested list inside it, then a numbered list from 1 to 3

- (or *, +) for bullets, 1. for numbers; indent to nest. The numbers come from the text, so a list can start at any number — but only a list starting at 1. can begin inside a paragraph, so prose that wraps onto a line starting 14. stays prose. A line directly after an item continues it; leave a blank line to end the list.

styleSheet: const GptMarkdownStyleSheet(
list: ListStyle(
bulletSize: 5,
bulletColor: Colors.indigo,
bulletShape: BoxShape.rectangle,
indent: 12,
gapAfterMarker: 12,
markerTextStyle: TextStyle(fontWeight: FontWeight.w600),
),
),

markerTextStyle is the 1. on an ordered list. bulletSize and bulletColor default to values derived from the surrounding text, so they track your font size unless you pin them.

How ordered and unordered list items are drawn.

Set it as GptMarkdownStyleSheet(list: ListStyle(…)) 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
bulletSize double? Bullet diameter. Defaults to 0.3x the font size.
bulletColor Color? Bullet colour. Defaults to the text colour.
bulletShape BoxShape? Bullet shape. Defaults to a circle.
markerTextStyle TextStyle? Style of the 1. marker. Defaults to weight 100.
indent double? Space before the marker. Defaults to the value each list kind already used — 7 for bullets, 6 for numbers.
gapAfterMarker double? Space between marker and text. Defaults to the value each list kind already used — 10 for bullets, 6 for numbers.
Member Type Description
merge(ListStyle? other) ListStyle This style, with any unset field taken from other, field by field.
resolve(ColorScheme scheme) ListStyle This style with every remaining default filled in.
copyWith({…}) ListStyle A copy with the given fields replaced.
static lerp(ListStyle? a, ListStyle? b, double t) ListStyle? Linearly interpolates between two styles.
resolve: more

Bullet size and colour depend on the surrounding text, so they stay null here and are computed per item unless set.

The ordered list builder.

typedef OrderedListBuilder = Widget Function(
BuildContext context,
String no,
Widget child,
GptMarkdownConfig config,
);

The unordered list builder.

typedef UnOrderedListBuilder = Widget Function(
BuildContext context,
Widget child,
GptMarkdownConfig config,
);