TextComponent class Components
A UI component that displays styled text in a terminal or canvas-based layout.
A TextComponent renders a string of text with optional styling such as colors, font attributes, and padding/margin (via TextComponentStyle).
The text is rendered exactly as provided, with line breaks respected. Spacing is determined by the configured padding and margin values.
Example
final component = TextComponent(
"Hello, World!",
style: TextComponentStyle(
color: AnsiColorType.green,
styles: {FontStyle.bold},
padding: EdgeInsets.symmetric(horizontal: 1),
),
);
See Also
- TextComponentStyle for defining style attributes.
- CanvasBuffer for low-level drawing.
- Component for the base UI element contract.
Constructors
- TextComponent.new(String text, {TextComponentStyle? style})
-
Creates a TextComponent with the given
text
and optionalstyle
.const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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
- style → TextComponentStyle?
-
The style applied to the text.
final
- text → String
-
The text content to display.
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