Closed SAGARSURI closed 2 years ago
I have the following code that update the yaml content:
final editor = YamlEditor(mppm.toString()); editor.appendToList(['packages'], "*"); print(editor);
Output is:
{name: mppm, packages: [packages/*, "*"]}
But I am curious how can I add this content back to the yaml file?
If I use the following code to update the yaml file. It just add it as a normal string without any proper formatting:
File("pubspec-output.yaml").writeAsStringSync(editor.toString());
You'll need to have the original String for the file, and then apply the edits from the YamlEditor
edits
YamlEditor
https://pub.dev/documentation/yaml_edit/latest/yaml_edit/YamlEditor/edits.html
I have the following code that update the yaml content:
Output is:
But I am curious how can I add this content back to the yaml file?
If I use the following code to update the yaml file. It just add it as a normal string without any proper formatting: