mapToString method

String mapToString (Map m)

Implementation

static String mapToString(Map m) {
  // Reuses the list in IterableBase for detecting toString cycles.
  if (_isToStringVisiting(m)) {
    return '{...}';
  }

  var result = StringBuffer();
  try {
    _toStringVisiting.add(m);
    result.write('{');
    bool first = true;
    m.forEach((k, v) {
      if (!first) {
        result.write(', ');
      }
      first = false;
      result.write(k);
      result.write(': ');
      result.write(v);
    });
    result.write('}');
  } finally {
    assert(identical(_toStringVisiting.last, m));
    _toStringVisiting.removeLast();
  }

  return result.toString();
}