mapToString static method

String mapToString(
  1. Map<Object?, Object?> m
)

Implementation

static String mapToString(Map<Object?, Object?> m) {
  // Reuses the list used by Iterable for detecting toString cycles.
  if (isToStringVisiting(m)) {
    return '{...}';
  }

  var result = StringBuffer();
  try {
    toStringVisiting.add(m);
    result.write('{');
    bool first = true;
    m.forEach((Object? k, Object? 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();
}