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<
Prints something after another printer.T> , provided by the SequencePrinterPrinterExtension extension -
around(
Object first, [Object? second]) → Printer< T> -
Available on Printer<
Prints something before and after another printer.T> , provided by the SequencePrinterPrinterExtension extension -
before(
Object other) → Printer< T> -
Available on Printer<
Prints before another printer.T> , provided by the SequencePrinterPrinterExtension extension -
call(
T object) → String -
Prints the
object
.inherited -
cast<
T> () → Printer< T> -
Available on Printer<
Returns a printer that accepts values of typeR> , provided by the ResultOfPrinterExtension extensionT
and casts them toR
for printing. -
ifEmpty(
[String label = '\u2205']) → Printer< Iterable< T> > -
Available on Printer<
PrintsIterable< , provided by the EmptyPrinterExtension extensionT> >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<
PrintsT> , provided by the NullPrinterExtension extensionlabel
, 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< ? emptyPrinter, Printer<T> >Iterable< ? beforePrinter, Printer<T> >Iterable< ? afterPrinter, String separator = ', ', String? lastSeparator, int? leadingItems, int? trailingItems, String? ellipses = '\u2026'}) → Printer<T> >Iterable< T> > -
Available on Printer<
Joins the items in an Iterable with a separator, and possibly limits the total amount of items to be printed.T> , provided by the IterablePrinterExtension extension -
mapIf(
bool condition, Printer< T> callback(Printer<T> printer)) → Printer<T> -
Available on Printer<
Helper to modify a printer with aT> , provided by the BuilderPrinterExtension extensioncallback
, if acondition
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<
Returns a printer that accepts values of typeR> , provided by the ResultOfPrinterExtension extensionT
and invokes the providedcallback
to transform it to typeR
for printing. -
padBoth(
int width, [String padding = ' ']) → Printer< T> -
Available on Printer<
Pads the string on the left and right if it is shorter thanT> , provided by the PadPrinterExtension extensionwidth
. -
padLeft(
int width, [String padding = ' ']) → Printer< T> -
Available on Printer<
Pads the string on the left if it is shorter thanT> , provided by the PadPrinterExtension extensionwidth
. -
padRight(
int width, [String padding = ' ']) → Printer< T> -
Available on Printer<
Pads the string on the right if it is shorter thanT> , provided by the PadPrinterExtension extensionwidth
. -
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
intobuffer
.override -
separateLeft(
int width, int offset, String separator) → Printer< T> -
Available on Printer<
Separates a string from the left side with aT> , provided by the SeparatePrinterExtension extensionseparator
everywidth
characters. -
separateRight(
int width, int offset, String separator) → Printer< T> -
Available on Printer<
Separates a string from the right side with aT> , provided by the SeparatePrinterExtension extensionseparator
everywidth
characters. -
skip(
int count) → Printer< T> -
Available on Printer<
Skips all but the firstT> , provided by the TakeSkipPrinterExtension extensioncount
characters. -
skipLast(
int count) → Printer< T> -
Available on Printer<
Skips all but the lastT> , provided by the TakeSkipPrinterExtension extensioncount
characters. -
take(
int count) → Printer< T> -
Available on Printer<
Takes the firstT> , provided by the TakeSkipPrinterExtension extensioncount
characters. -
takeLast(
int count) → Printer< T> -
Available on Printer<
Takes the lastT> , provided by the TakeSkipPrinterExtension extensioncount
characters. -
toString(
) → String -
Standard
toString
implementation. Do not override, instead implement toStringPrinter to customize.inherited -
trim(
) → Printer< T> -
Available on Printer<
Removes any leading and trailing whitespace.T> , provided by the TrimPrinterExtension extension -
trimLeft(
) → Printer< T> -
Available on Printer<
Removes any leading whitespace.T> , provided by the TrimPrinterExtension extension -
trimRight(
) → Printer< T> -
Available on Printer<
Removes any trailing whitespace.T> , provided by the TrimPrinterExtension extension -
truncateCenter(
int width, {String ellipsis = defaultEllipsis, TruncateMethod method = TruncateMethod.characters}) → Printer< T> -
Available on Printer<
Truncates the string from the center if it is longer than width.T> , provided by the TruncatePrinterExtension extension -
truncateLeft(
int width, {String ellipsis = defaultEllipsis, TruncateMethod method = TruncateMethod.characters}) → Printer< T> -
Available on Printer<
Truncates the string from the left side if it is longer than width.T> , provided by the TruncatePrinterExtension extension -
truncateRight(
int width, {String ellipsis = defaultEllipsis, TruncateMethod method = TruncateMethod.characters}) → Printer< T> -
Available on Printer<
Truncates the string from the right side if it is longer than width.T> , provided by the TruncatePrinterExtension extension -
where(
Predicate1< T> callback) → Printer<T> -
Available on Printer<
Returns a printer that only prints the receiver if theT> , provided by the WherePrinterExtension extensioncallback
evaluates totrue
.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited