ToStringPrinter mixin

A mixin to provide a consistent toString() implementation.

Add the mixin to the root of your object hierarchy and override the toStringPrinter accessor:

@override
ObjectPrinter get toStringPrinter => super.toStringPrinter
  ..addValue(someField, name: 'someField')
  ..addValue(otherField, name: 'otherField');

Note: Due to the lack of a Self type in Dart, this is working with a dynamically typed printer Object. To avoid loosing the type information use addValue instead of addCallback to configure the field printers (https://github.com/dart-lang/sdk/issues/28477).

Mixin Applications

Properties

defaultToStringPrinter ObjectPrinter
Override to configure the empty ObjectPrinter.
no setter
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 setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Standard toString implementation. Do not override, instead implement toStringPrinter to customize.
override

Operators

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