debugString method

  1. @override
String debugString(
  1. T instance
)
override

Constructs a string for debugging instance.

Implementation

@override
String debugString(T instance) {
  final mapper = _DebugStringMapper();
  map(mapper, instance);
  final parts = mapper._parts;
  final constructorIdentifier = mapper._constructorIdentifier;

  final sb = StringBuffer();
  final classIdentifier = instance.runtimeType.toString();
  sb.write(classIdentifier);

  // Custom constructor?
  if (constructorIdentifier != null) {
    sb.write('.');
    sb.write(constructorIdentifier);
  }

  sb.write('(');
  sb.write(ListKind.debugStringForIterableElements(
    iterable: parts,
    debugString: (e) => e,
    maxLineLength:
        30 - classIdentifier.length - ((constructorIdentifier ?? '').length),
  ));
  sb.write(')');
  return sb.toString();
}