OutputFormatter class

Formats structured output for terminal display.

Supports multiple OutputFormat modes and applies colors from the active OutputTheme.

Constructors

OutputFormatter({OutputFormat format = OutputFormat.rich, OutputTheme theme = const OutputTheme()})

Properties

format OutputFormat
The current output format.
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
theme OutputTheme
The active color theme.
getter/setter pair

Methods

formatBytes(int bytes) String
Formats a byte count in human-readable units (KB, MB, GB).
formatCost(double cost) String
Formats a dollar cost value (e.g. $0.00, $1.23).
formatDiff(String diff, {bool colorize = true}) String
Formats a unified diff string with optional ANSI colors.
formatDuration(Duration duration) String
Formats a Duration as a human-readable string (e.g. 2m 13s).
formatError(Object error, {StackTrace? stackTrace, bool verbose = false}) String
Formats an error message with optional stack trace.
formatFileList(List<String> files, {List<int>? sizes, List<DateTime>? dates, bool showSize = false, bool showDate = false}) String
Formats a list of file paths with optional size and date columns.
formatProgress(int current, int total, {String? label, int barWidth = 30}) String
Renders an ASCII progress bar.
formatTable(List<String> headers, List<List<String>> rows, {List<ColumnAlignment>? alignment, bool border = true}) String
Formats a table with aligned columns and optional borders.
formatTokenCount(int tokens) String
Formats a token count with K/M suffixes.
formatToolOutput(String toolName, String output, {OutputFormat? format}) String
Formats tool execution output with a header.
highlightMatches(String text, Pattern pattern) String
Highlights occurrences of pattern within text using the theme's highlight color.
indentBlock(String text, {int level = 1, String char = ' '}) String
Indents every line of text by level repetitions of char.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
truncateWithEllipsis(String text, int maxLength) String
Truncates text to maxLength characters, appending an ellipsis.
wrapInBox(String text, {String? title, int? width}) String
Wraps text in an ASCII box with an optional title.

Operators

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