writeMap method

void writeMap(
  1. int indent,
  2. Map<String, dynamic> map
)

Implementation

void writeMap(int indent, Map<String, dynamic> map) {
  buffer.write('{\n');
  for (final entry in map.entries) {
    if (entry.key.contains("'")) {
      buffer.write(
        '${_generateIndent(indent)}"${entry.key}": ',
      );
    } else {
      buffer.write(
        "${_generateIndent(indent)}'${entry.key}': ",
      );
    }
    if (entry.value is List) {
      writeList(indent + 2, entry.value);
    } else if (entry.value is Map) {
      writeMap(indent + 2, entry.value);
    } else if (entry.value is String) {
      writeString(0, entry.value);
    } else {
      writeAny(0, entry.value);
    }
    buffer.write(',\n');
  }
  buffer.write('${_generateIndent(indent - 2)}}');
}