writeMap method
void
writeMap(
- int indent,
- Map<String, dynamic> map, {
- bool stringAsAny = false,
})
Implementation
void writeMap(
int indent,
Map<String, dynamic> map, {
/// If `true`, `String` will be treated as a generic value, thus no quote characters
/// will be written.
bool stringAsAny = false,
}) {
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,
stringAsAny: stringAsAny,
);
} else if (entry.value is Map) {
writeMap(
indent + 2,
entry.value,
stringAsAny: stringAsAny,
);
} else if (stringAsAny) {
writeAny(0, 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)}}');
}