writeAsYaml method

void writeAsYaml({
  1. required StringBuffer buffer,
  2. required List<MapEntry> payload,
  3. int spacing = 2,
})

Implementation

void writeAsYaml(
    {required StringBuffer buffer,
    required List<MapEntry> payload,
    int spacing = 2}) {
  for (final entry in payload) {
    final spaces = ' ' * spacing;

    if (entry.value is String) {
      buffer.writeln('$spaces${entry.key}: ${entry.value}');
    } else if (entry.value is Map) {
      buffer.writeln('$spaces${entry.key}:');

      writeAsYaml(
          buffer: buffer,
          payload: (entry.value as dynamic).entries.toList(),
          spacing: spacing + 2);
    }
  }
}