AnsiStyled class
Applies foreground and/or background color and text styles to a child span.
Supports all common ANSI SGR text attributes:
- foreground and background colors
- bold (SGR 1) - increased intensity
- dim (SGR 2) - decreased intensity
- italic (SGR 3) - italic text
- underline (SGR 4) - underlined text
- strikethrough (SGR 9) - crossed-out text
Example:
AnsiStyled(
foreground: Ansi16.red,
bold: true,
underline: true,
child: PlainText('Important!'),
)
- Inheritance
-
- Object
- LogSpan
- SingleChildSpan
- AnsiStyled
- Annotations
-
- @experimental
Constructors
- AnsiStyled({LogSpan? child, ConsoleColor? foreground, ConsoleColor? background, bool bold = false, bool dim = false, bool italic = false, bool underline = false, bool strikethrough = false})
-
Creates a styled span that applies ANSI formatting to its
child.
Properties
-
allAncestors
→ Iterable<
LogSpan> -
Returns all ancestors from parent to root.
no setterinherited
-
allChildren
→ Iterable<
LogSpan> -
All direct children of this span.
no setterinherited
-
allDescendants
→ Iterable<
LogSpan> -
Returns all descendants (including self) in pre-order.
no setterinherited
- background → ConsoleColor?
-
The background color to apply behind the text.
final
- bold → bool
-
Whether to apply bold styling (ANSI SGR code 1).
final
- child ↔ LogSpan?
-
The single child of this span.
getter/setter pairinherited
- dim → bool
-
Whether to apply dim/faint styling (ANSI SGR code 2).
final
- foreground → ConsoleColor?
-
The foreground (text) color to apply.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- italic → bool
-
Whether to apply italic styling (ANSI SGR code 3).
final
- parent → LogSpan?
-
Parent span in the tree, or null if this is the root.
no setterinherited
- root → LogSpan
-
Returns the root span of the tree.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- strikethrough → bool
-
Whether to apply strikethrough styling (ANSI SGR code 9).
final
- underline → bool
-
Whether to apply underline styling (ANSI SGR code 4).
final
Methods
-
build(
) → LogSpan -
Builds this span into another span, or returns itself if already terminal.
inherited
-
findAll<
T extends LogSpan> () → Iterable< T> -
Finds all descendants (including self) of type
T.inherited -
findFirst<
T extends LogSpan> () → T? -
Finds the first descendant (including self) of type
T.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
) → bool -
Removes this span from its parent.
inherited
-
render(
ConsoleMessageBuffer buffer) → void -
Renders this span to the
buffer.override -
replaceWith(
LogSpan newSpan) → bool -
Replaces this span in its parent with
newSpan.inherited -
toString(
) → String -
A string representation of this object.
override
-
wrap(
LogSpan wrapper(LogSpan child)) → void -
Wraps this span with a wrapper span.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited