loadYamlDocuments function

List<YamlDocument> loadYamlDocuments(
  1. String yaml, {
  2. Uri? sourceUrl,
})

Loads a stream of documents from a YAML string.

This is like loadYamlStream, except that it returns YamlDocuments with metadata wrapping the document contents.

Implementation

List<YamlDocument> loadYamlDocuments(String yaml, {Uri? sourceUrl}) {
  var loader = Loader(yaml, sourceUrl: sourceUrl);

  var documents = <YamlDocument>[];
  var document = loader.load();
  while (document != null) {
    documents.add(document);
    document = loader.load();
  }

  return documents;
}