CheckboxList class Components InteractableComponents
A scrollable list of checkboxes arranged either vertically or horizontally.
The CheckboxList component renders a list of labeled checkboxes, supports
navigation via arrow keys, and allows toggling selections with the space
or enter
keys.
Each item in the list is represented as a Checkbox component internally. Focus and hover states are managed to provide interactive feedback.
Features
- Vertical or horizontal layout (direction).
- Customizable spacing between items (spacing).
- Supports ANSI color customization for selected, hovered, and text states.
- Optional border styling using BorderStyle.
- Keyboard navigation with arrow keys.
- Selection toggling via
space
orenter
.
Example
CheckboxList(
items: ['Option A', 'Option B', 'Option C'],
selectionColor: AnsiColorType.green,
hoverColor: AnsiColorType.yellow,
textColor: AnsiColorType.white,
borderStyle: BorderStyle.rounded,
spacing: 1,
direction: Axis.vertical,
)
See also
- Checkbox — the individual checkbox component used by CheckboxList.
- BorderStyle — to customize the border appearance.
- Axis — to control vertical or horizontal layout.
Constructors
-
CheckboxList.new({required List<
String> items, AnsiColorType? selectionColor, AnsiColorType? hoverColor, AnsiColorType? textColor, BorderStyle? borderStyle, int spacing = 1, Axis direction = Axis.vertical, EdgeInsets padding = const EdgeInsets.all(1)}) -
Padding applied around the entire checkbox list.
Creates a CheckboxList.
const
Properties
- borderStyle → BorderStyle?
-
The style of the border drawn around the checkbox list.
final
- direction → Axis
-
The layout direction of the list — either Axis.vertical or Axis.horizontal.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hoverColor → AnsiColorType?
-
The ANSI color applied to a hovered checkbox.
final
-
items
→ List<
String> -
The text labels for each checkbox.
final
- padding → EdgeInsets
-
The padding inside the component’s layout bounds.
finalinherited
- position → Position?
-
The position of the component within its parent or layout.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectionColor → AnsiColorType?
-
The ANSI color applied to selected checkboxes.
final
- spacing → int
-
The number of character spaces between adjacent checkboxes.
final
- textColor → AnsiColorType?
-
The ANSI color applied to checkbox labels.
final
Methods
-
createInstance(
) → ComponentInstance -
Creates a ComponentInstance that can be rendered.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited