ObjectPrinter<T> class

Configurable printer for standard objects.

Inheritance
Available extensions
Annotations
  • @optionalTypeArgs

Constructors

ObjectPrinter.new(Printer<T> type, {String? beforeFields = defaultBeforeFields, Printer<String>? fieldName, String? fieldNameSeparator = defaultFieldNameSeparator, Printer<String>? fieldValue, String? fieldSeparator = defaultFieldSeparator, String? afterFields = defaultAfterFields})
Creates a custom object printer.
ObjectPrinter.dynamic({String? beforeFields = defaultBeforeFields, Printer<String>? fieldName, String? fieldNameSeparator = defaultFieldNameSeparator, Printer<String>? fieldValue, String? fieldSeparator = defaultFieldSeparator, String? afterFields = defaultAfterFields})
Creates an object printer based on the dynamic type.
ObjectPrinter.static({String? beforeFields = defaultBeforeFields, Printer<String>? fieldName, String? fieldNameSeparator = defaultFieldNameSeparator, Printer<String>? fieldValue, String? fieldSeparator = defaultFieldSeparator, String? afterFields = defaultAfterFields})
Creates an object printer based on the static type.

Properties

afterFields String?
String to print after the fields.
final
beforeFields String?
String to print before the fields.
final
defaultToStringPrinter ObjectPrinter
Override to configure the empty ObjectPrinter.
no setterinherited
fieldName Printer<String>?
Printer of the field name.
final
fieldNameSeparator String?
String to print between field name and value.
final
fields List<FieldPrinter<T>>
Fields to print.
final
fieldSeparator String?
String to print between fields themselves.
final
fieldValue Printer<String>?
Printer of the field value.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
toStringPrinter ObjectPrinter
Override and call super to add values to the ObjectPrinter.
no setteroverride
type Printer<T>
Printer of the object type.
final

Methods

addCallback<F>(Map1<T, F> callback, {String? name, Printer<F>? printer, bool omitNull = defaultOmitNull, Predicate2<T, F>? omitPredicate, int? index}) → void
Adds a callback field printer.
addField(FieldPrinter<T> field, {int? index}) → void
Adds a custom field printer.
addValue<F>(F value, {String? name, Printer<F>? printer, bool omitNull = defaultOmitNull, Predicate1<F>? omitPredicate, int? index}) → void
Adds a value field printer.
after(Object other) Printer<T>

Available on Printer<T>, provided by the SequencePrinterPrinterExtension extension

Prints something after another printer.
around(Object first, [Object? second]) Printer<T>

Available on Printer<T>, provided by the SequencePrinterPrinterExtension extension

Prints something before and after another printer.
before(Object other) Printer<T>

Available on Printer<T>, provided by the SequencePrinterPrinterExtension extension

Prints before another printer.
call(T object) String
Prints the object.
inherited
cast<T>() Printer<T>

Available on Printer<R>, provided by the ResultOfPrinterExtension extension

Returns a printer that accepts values of type T and casts them to R for printing.
ifEmpty([String label = '\u2205']) Printer<Iterable<T>>

Available on Printer<Iterable<T>>, provided by the EmptyPrinterExtension extension

Prints label, if the iterable to be printed is empty. Uses the unicode symbol for empty set by default: https://unicode-table.com/en/2205/.
ifNull([String label = '\u2400']) Printer<T?>

Available on Printer<T>, provided by the NullPrinterExtension extension

Prints label, if the object to be printed is null. Uses the unicode symbol for null by default: https://unicode-table.com/en/2400/.
iterable({Printer<Iterable<T>>? emptyPrinter, Printer<Iterable<T>>? beforePrinter, Printer<Iterable<T>>? afterPrinter, String separator = ', ', String? lastSeparator, int? leadingItems, int? trailingItems, String? ellipses = '\u2026'}) Printer<Iterable<T>>

Available on Printer<T>, provided by the IterablePrinterExtension extension

Joins the items in an Iterable with a separator, and possibly limits the total amount of items to be printed.
mapIf(bool condition, Printer<T> callback(Printer<T> printer)) Printer<T>

Available on Printer<T>, provided by the BuilderPrinterExtension extension

Helper to modify a printer with a callback, if a condition is met.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onResultOf<T>(Map1<T, R> function) Printer<T>

Available on Printer<R>, provided by the ResultOfPrinterExtension extension

Returns a printer that accepts values of type T and invokes the provided callback to transform it to type R for printing.
padBoth(int width, [String padding = ' ']) Printer<T>

Available on Printer<T>, provided by the PadPrinterExtension extension

Pads the string on the left and right if it is shorter than width.
padLeft(int width, [String padding = ' ']) Printer<T>

Available on Printer<T>, provided by the PadPrinterExtension extension

Pads the string on the left if it is shorter than width.
padRight(int width, [String padding = ' ']) Printer<T>

Available on Printer<T>, provided by the PadPrinterExtension extension

Pads the string on the right if it is shorter than width.
print(T object) String
Returns the printed object.
inherited
printFieldOn(T object, FieldPrinter<T> field, StringBuffer buffer) → void
printFieldsOn(T object, StringBuffer buffer) → void
printOn(T object, StringBuffer buffer) → void
Prints the object into buffer.
override
separateLeft(int width, int offset, String separator) Printer<T>

Available on Printer<T>, provided by the SeparatePrinterExtension extension

Separates a string from the left side with a separator every width characters.
separateRight(int width, int offset, String separator) Printer<T>

Available on Printer<T>, provided by the SeparatePrinterExtension extension

Separates a string from the right side with a separator every width characters.
skip(int count) Printer<T>

Available on Printer<T>, provided by the TakeSkipPrinterExtension extension

Skips all but the first count characters.
skipLast(int count) Printer<T>

Available on Printer<T>, provided by the TakeSkipPrinterExtension extension

Skips all but the last count characters.
take(int count) Printer<T>

Available on Printer<T>, provided by the TakeSkipPrinterExtension extension

Takes the first count characters.
takeLast(int count) Printer<T>

Available on Printer<T>, provided by the TakeSkipPrinterExtension extension

Takes the last count characters.
toString() String
Standard toString implementation. Do not override, instead implement toStringPrinter to customize.
inherited
trim() Printer<T>

Available on Printer<T>, provided by the TrimPrinterExtension extension

Removes any leading and trailing whitespace.
trimLeft() Printer<T>

Available on Printer<T>, provided by the TrimPrinterExtension extension

Removes any leading whitespace.
trimRight() Printer<T>

Available on Printer<T>, provided by the TrimPrinterExtension extension

Removes any trailing whitespace.
truncateCenter(int width, {String ellipsis = defaultEllipsis, TruncateMethod method = TruncateMethod.characters}) Printer<T>

Available on Printer<T>, provided by the TruncatePrinterExtension extension

Truncates the string from the center if it is longer than width.
truncateLeft(int width, {String ellipsis = defaultEllipsis, TruncateMethod method = TruncateMethod.characters}) Printer<T>

Available on Printer<T>, provided by the TruncatePrinterExtension extension

Truncates the string from the left side if it is longer than width.
truncateRight(int width, {String ellipsis = defaultEllipsis, TruncateMethod method = TruncateMethod.characters}) Printer<T>

Available on Printer<T>, provided by the TruncatePrinterExtension extension

Truncates the string from the right side if it is longer than width.
where(Predicate1<T> callback) Printer<T>

Available on Printer<T>, provided by the WherePrinterExtension extension

Returns a printer that only prints the receiver if the callback evaluates to true.

Operators

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