map2Lines method

  1. @visibleForTesting
String map2Lines(
  1. String key,
  2. int startIndent,
  3. int lineIndex,
  4. YamlMap map,
)

Implementation

@visibleForTesting
String map2Lines(String key, int startIndent, int lineIndex, YamlMap map) {
  StringBuffer output = StringBuffer();
  final newKey = key + ":";
  output.writeln(
      newKey.padLeft(lineIndex * _indent + newKey.length + startIndent));
  final keys = map.keys;
  for (int i = 0; i < keys.length; i++) {
    final k = keys.elementAt(i);
    final value = map[k];
    String line;
    if (value is YamlMap) {
      line = "$k:";
      output.write(map2Lines(k, startIndent, lineIndex + i + 1, value));
    } else {
      line = "$k: $value";
      output.writeln(line
          .padLeft((lineIndex + 1) * _indent + line.length + startIndent));
      continue;
    }
  }

  return output.toString();
}