toString method

  1. @override
String toString({
  1. String prefix = '',
  2. bool showTimestamp = true,
  3. bool showOrdinals = true,
  4. bool showChildren = true,
})
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.

Implementation

@override
String toString(
    {String prefix = '',
    bool showTimestamp = true,
    bool showOrdinals = true,
    bool showChildren = true}) {
  var sb = StringBuffer();
  sb.write(prefix);
  sb.write(path);
  if (showOrdinals || showTimestamp) {
    sb.write('[');
  }
  if (tombstone) {
    if (showOrdinals) {
      sb.write('<tombstone>,');
    }
  }
  if (skeleton) {
    if (showOrdinals) {
      sb.write('{<skeletonized>}');
    }
  } else {
    if (showOrdinals) {
      sb.write('owner=');
      sb.write(_ordinals[Field.owner]);
      sb.write(',visibility=');
      sb.write(_ordinals[Field.visibility]);
    }
    if (showOrdinals && showTimestamp) {
      sb.write(',');
    }
    if (showTimestamp) {
      sb.write('lastModified=');
      sb.write(_ordinals[Field.lastModified]);
    }
  }
  if (showOrdinals || showTimestamp) {
    sb.write(']');
  }
  sb.write('{');
  var i = 0;
  if (skeleton) {
    sb.write('{<skeletonized>}');
  } else {
    if (_values.length == 1) {
      sb.write(_values.values.first.toString());
    } else if (_values.isNotEmpty) {
      sb.write('\n');
      for (NodeValue e in _values.values) {
        if (i > 0) {
          sb.write(', \n');
        }
        sb.write(e.toString('$prefix   '));
        i++;
      }
      sb.write('\n');
      sb.write(prefix);
    }
  }
  sb.write('}');
  if (_childNodes.isNotEmpty && showChildren) {
    sb.write(' children{');
    int i = 0;
    for (Node element in _childNodes.values) {
      sb.write('${element.name}${++i == _childNodes.length ? "" : ", "}');
    }
    sb.write('}');
  }
  return sb.toString();
}