BoxBuilder class

A fluent builder for creating styled boxes.

Provides a chainable API for box configuration with support for the new Style system, custom borders, and per-line content styling.

final box = BoxBuilder()
    .title('Welcome')
    .content('Hello, World!\nThis is a styled box.')
    .border(Border.rounded)
    .titleStyle(Style().bold().foreground(Colors.cyan))
    .borderStyle(Style().foreground(Colors.gray))
    .padding(1, 2)
    .width(50)
    .render();

print(box);
Inheritance
Available extensions

Constructors

BoxBuilder({RenderConfig renderConfig = const RenderConfig()})
Creates a new empty box builder.

Properties

hashCode int
The hash code for this object.
no setterinherited
lineCount int
Number of lines in render.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

border(Border border) BoxBuilder
Sets the border style (characters).
borderStyle(Style style) BoxBuilder
Sets the border text style.
content(String text) BoxBuilder
Sets the box content from a string.
contentAlign(BoxAlign align) BoxBuilder
Sets the content alignment.
contentStyle(Style style) BoxBuilder
Sets the content text style (applied to all content).
contentStyleFunc(BoxContentStyleFunc func) BoxBuilder
Sets the content style function for per-line styling.
init() Cmd?
Returns an optional command to execute on program startup.
inherited
line(String text) BoxBuilder
Adds a line to the box content.
lines(List<String> lines) BoxBuilder
Sets the box content from a list of lines.
margin(int vertical, [int? horizontal]) BoxBuilder
Sets uniform margin (all sides).
marginAll({int? top, int? right, int? bottom, int? left}) BoxBuilder
Sets individual margin values.
maxWidth(int value) BoxBuilder
Sets the maximum width of the box.
minWidth(int value) BoxBuilder
Sets the minimum width of the box.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
padding(int vertical, [int? horizontal]) BoxBuilder
Sets uniform padding (all sides).
paddingAll({int? top, int? right, int? bottom, int? left}) BoxBuilder
Sets individual padding values.
render() String
Renders the component as a string.
override
title(String title) BoxBuilder
Sets the box title.
titleAlign(BoxAlign align) BoxBuilder
Sets the title alignment.
titleStyle(Style style) BoxBuilder
Sets the title text style.
toString() String
A string representation of this object.
inherited
update(Msg msg) → (ViewComponent, Cmd?)
Updates the component state in response to a message.
inherited
view() String
Renders the current model state for display.
inherited
width(int value) BoxBuilder
Sets the fixed width of the box.
writelnTo(Console io) → void

Available on DisplayComponent, provided by the DisplayComponentExtension extension

Renders the component and writes it to the console.

Operators

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