Aligned class

Aligns child content within a fixed-width column.

Use Aligned to create consistent column widths in formatted output, useful for aligning log levels, timestamps, or other fixed-width fields.

Example

// Left-align log level in 8-character column
Aligned(
  width: 8,
  align: HorizontalAlign.left,
  child: BracketedLogLevel(record.level),
)
// "[info]  " (padded to 8 chars)

// Right-align timestamp
Aligned(
  width: 12,
  align: HorizontalAlign.right,
  child: Timestamp(record.date),
)

// Center-align content
Aligned(
  width: 20,
  align: HorizontalAlign.center,
  child: PlainText('centered'),
)
// "      centered      "
Inheritance
Annotations
  • @experimental

Constructors

Aligned({required int width, required HorizontalAlign align, required LogSpan? child})
Creates an aligned span with fixed width.

Properties

align HorizontalAlign
The horizontal alignment of the content within the column.
final
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
child LogSpan?
The single child of this span.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
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
width int
The fixed width of the column in characters.
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.
inherited
wrap(LogSpan wrapper(LogSpan child)) → void
Wraps this span with a wrapper span.
inherited

Operators

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