LineBuilder class

LineBuilder – Centralized line-level styling utilities for terminal views.

Provides reusable, theme-aware methods for common UI patterns found across terminal views and prompts. Eliminates duplication and ensures consistency.

Key patterns centralized:

  • Frame prefix (left gutter with border vertical)
  • Arrow/focus indicators
  • Checkbox rendering
  • Overflow indicators
  • Line wrapping with optional inverse highlight

Usage:

final lb = LineBuilder(theme);

// Frame prefix for content lines
out.writeln('${lb.gutter()}Content here');

// Arrow indicator for focused item
final arrow = lb.arrow(isFocused);
out.writeln('${lb.gutter()}$arrow Item');

// Checkbox for toggleable items
final check = lb.checkbox(isChecked);
out.writeln('${lb.gutter()}$check Option');

// Full line with optional inverse highlight
lb.writeLine(out, 'Content', highlighted: isFocused);

// Overflow indicators for scrollable lists
if (hasOverflowAbove) out.writeln(lb.overflowLine());

Benefits:

  • Single source of truth for styling patterns
  • Consistent appearance across all views
  • Easier theming customization
  • Reduced boilerplate in view code
  • Better testability

Constructors

LineBuilder(PromptTheme theme)
Creates a LineBuilder with the given theme.
const

Properties

features → DisplayFeatures
Shorthand access to the theme's feature configuration.
no setter
glyphs → TerminalGlyphs
Shorthand access to the theme's glyph configuration.
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
theme → PromptTheme
The theme providing colors and style symbols.
final

Methods

arrow(bool focused) → String
Returns the arrow/focus indicator based on focus state.
arrowAccent() → String
Returns an accented arrow (always visible, used for bullets).
arrowDim() → String
Returns a dimmed arrow (for inactive/non-focused items).
checkbox(bool checked) → String
Returns a styled checkbox based on checked state.
checkboxHighlighted(bool checked, {bool highlight = false}) → String
Returns a highlighted checkbox (for focused items).
checkboxLine(String content, {required bool focused, required bool checked}) → String
Builds a checkbox item line.
emptyLine(String message) → String
Returns a complete empty message line with gutter prefix.
emptyMessage(String message) → String
Returns a dimmed placeholder message in parentheses.
gutter() → String
Returns the standard left gutter/frame prefix.
gutterOnly() → String
Returns a gutter-only line (no trailing space, just the border).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
overflow() → String
Returns the overflow indicator text (dimmed ellipsis).
overflowLine() → String
Returns a complete overflow line with gutter prefix.
selectableLine(String content, {required bool focused}) → String
Builds a standard selectable item line.
switchControl(bool on) → String
Returns a styled switch/toggle control.
switchControlHighlighted(bool on, {bool highlight = false}) → String
Returns a highlighted switch control (for focused items).
toString() → String
A string representation of this object.
inherited
writeCheckboxLine(RenderOutput out, String content, {required bool focused, required bool checked, bool highlighted = false}) → void
Writes a checkbox item line with full formatting.
writeLine(RenderOutput out, String content, {bool highlighted = false, bool includeGutter = true}) → void
Writes a content line to the output with optional inverse highlight.
writeLines(RenderOutput out, Iterable<String> lines, {bool includeGutter = true}) → void
Writes multiple content lines with the same settings.
writeSelectableLine(RenderOutput out, String content, {required bool focused, bool highlighted = false}) → void
Writes a selectable item line with full formatting.

Operators

operator ==(Object other) → bool
The equality operator.
inherited