Skip to content
Talk to an engineerRequest access

Task list

Checkboxes from - [x] and radio options from (x).

Two checked and one unchecked task, then a choice with “Monthly” selected and “Yearly” not

- [x] and - [ ] make a task list; (x) and ( ) make radio options. Both are read-only unless CheckboxStyle(interactive: true); then a tap calls onCheckboxChanged.

Applies to both - [x] task lists and (x) radio options.

styleSheet: const GptMarkdownStyleSheet(
checkbox: CheckboxStyle(
size: 18,
checkedColor: Colors.green,
borderRadius: Radius.circular(4),
gapAfterBox: 8,
),
),

To make them interactive you must opt in and persist the result yourself:

GptMarkdown(
markdown,
styleSheet: const GptMarkdownStyleSheet(
checkbox: CheckboxStyle(interactive: true),
),
onCheckboxChanged: (value) {
// Rewrite the source, or the tick reverts on the next build.
setState(() => markdown = toggleFirstUnchecked(markdown));
},
)

How a task-list checkbox or radio button is drawn.

Set it as GptMarkdownStyleSheet(checkbox: CheckboxStyle(…)) 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
size double? Box size. Defaults to the Material default.
checkedColor Color? Fill when checked. Defaults to the Material default.
uncheckedColor Color? Border when unchecked. Defaults to the Material default.
checkColor Color? The tick itself. Defaults to the Material default.
borderRadius Radius? Corner rounding of a checkbox.
gapAfterBox double? Space between the box and its label. Defaults to 5.
interactive bool? Whether taps are accepted. Defaults to false.
Member Type Description
merge(CheckboxStyle? other) CheckboxStyle This style, with any unset field taken from other, field by field.
resolve(ColorScheme scheme) CheckboxStyle This style with every remaining default filled in.
copyWith({…}) CheckboxStyle A copy with the given fields replaced.
static lerp(CheckboxStyle? a, CheckboxStyle? b, double t) CheckboxStyle? Linearly interpolates between two styles.
resolve: more

Colours left null use Material’s own checkbox and radio defaults, so the widgets keep following the app theme.

Replaces the whole checkbox row.

typedef CheckboxBuilder = Widget Function(
BuildContext context,
bool checked,
Widget content,
CheckboxStyle style,
);

Replaces the whole radio row.

typedef RadioOptionBuilder = Widget Function(
BuildContext context,
bool selected,
Widget content,
CheckboxStyle style,
);

Called when a task-list checkbox is tapped.

Only fires when CheckboxStyle.interactive is set — Markdown checkboxes render the source text, so they are read-only unless you opt in.

void Function(bool value)? onCheckboxChanged