format method

String format({
  1. int indent = 0,
})

Implementation

String format({int indent = 0}) =>
    '''{
${data.entries.map((e) {
      if (e.value is Document) {
        final docStr = (e.value as Document).format(indent: indent + 1).split('\n').map((line) => '  $line').join('\n');
        return "${'  ' * indent}${e.key} => $docStr";
      }

      if (e.value is List<Document>) {
        final listStr = (e.value as List<Document>).map((item) => item.format(indent: indent + 1).split('\n').map((line) => '  $line').join('\n')).join(',\n  ');
        return "${'  ' * indent}${e.key} => (${(e.value as List<Document>).length}) [\n$listStr\n  ]";
      }
      return "${'  ' * indent}${e.key} => ${e.value}";
    }).join(",\n  ")}
${'  ' * indent}}''';