BorderRenderer class Border Component Rendering
A utility class responsible for rendering borders around rectangular areas in the terminal UI using a specified BorderStyle and optional color.
The border is drawn on a CanvasBuffer, and the inner content is rendered via a provided callback function, which receives the reduced inner bounds.
This class abstracts the drawing of consistent, styled borders, supporting custom border characters and coloring.
Example
final borderRenderer = BorderRenderer(
style: BorderStyle.rounded,
borderColor: AnsiColorType.blue,
);
borderRenderer.draw(buffer, Rect(x: 0, y: 0, width: 10, height: 5), (buf, innerBounds) {
// Draw child content inside the border
buf.drawAt(innerBounds.x, innerBounds.y, 'Content inside border');
});
See Also
- BorderStyle: Defines the characters used to draw the border.
- CanvasBuffer: The canvas on which the border and contents are drawn.
- AnsiColorType: Used for coloring the border.
This class is commonly used in terminal UI components that need framed or boxed layouts.
Constructors
- BorderRenderer.new({required BorderStyle style, AnsiColorType? borderColor})
-
Creates a BorderRenderer with the given
style
and optionalborderColor
.
Properties
- borderColor ↔ AnsiColorType?
-
Optional ANSI color to apply to the border characters.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- style → BorderStyle
-
The style of the border to render (characters for corners, sides, etc.).
final
Methods
-
draw(
CanvasBuffer buffer, Rect bounds, void drawChild(CanvasBuffer buffer, Rect bounds)) → void -
Draws the border on the provided
buffer
within the givenbounds
. -
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