toString method Null safety

  1. @override
String toString(
  1. {TextTreeConfiguration? parentConfiguration,
  2. DiagnosticLevel minLevel = DiagnosticLevel.info}
)
override

Returns a string representation of this diagnostic that is compatible with the style of the parent if the node is not the root.

parentConfiguration specifies how the parent is rendered as text art. For example, if the parent places all properties on one line, the toString for each property should avoid line breaks if possible.

minLevel specifies the minimum DiagnosticLevel for properties included in the output.

In release mode, far less information is retained and some information may not print at all.

Implementation

@override
String toString({
  TextTreeConfiguration? parentConfiguration,
  DiagnosticLevel minLevel = DiagnosticLevel.info,
}) {
  String result = super.toString();
  assert(style != null);
  assert(minLevel != null);
  assert(() {
    if (_isSingleLine(style)) {
      result = toStringDeep(parentConfiguration: parentConfiguration, minLevel: minLevel);
    } else {
      final String description = toDescription(parentConfiguration: parentConfiguration);

      if (name == null || name!.isEmpty || !showName) {
        result = description;
      } else {
        result = description.contains('\n') ? '$name$_separator\n$description'
            : '$name$_separator $description';
      }
    }
    return true;
  }());
  return result;
}