W3cubDocs

/Dart 2

iterableToFullString method

String iterableToFullString (Iterable iterable, [ String leftDelimiter = '(', String rightDelimiter = ')' ])

Converts an Iterable to a string.

Converts each elements to a string, and separates the results by ", ". Then wraps the result in leftDelimiter and rightDelimiter.

Unlike iterableToShortString, this conversion doesn't omit any elements or puts any limit on the size of the result.

Handles circular references where converting one of the elements to a string ends up converting iterable to a string again.

Implementation

static String iterableToFullString(Iterable iterable,
    [String leftDelimiter = '(', String rightDelimiter = ')']) {
  if (_isToStringVisiting(iterable)) {
    return "$leftDelimiter...$rightDelimiter";
  }
  StringBuffer buffer = new StringBuffer(leftDelimiter);
  _toStringVisiting.add(iterable);
  try {
    buffer.writeAll(iterable, ", ");
  } finally {
    assert(identical(_toStringVisiting.last, iterable));
    _toStringVisiting.removeLast();
  }
  buffer.write(rightDelimiter);
  return buffer.toString();
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-collection/IterableBase/iterableToFullString.html