resolveFromYamlMap static method

String? resolveFromYamlMap(
  1. List<String> key,
  2. YamlMap cursor
)

Implementation

static String? resolveFromYamlMap(List<String> key, YamlMap cursor) {
  for (var i = 0; i < key.length - 1; i++) {
    var part = key[i];
    var newCursorValue = cursor.nodes[part];
    if (newCursorValue == null) return null;
    if (newCursorValue is! YamlMap) return null;
    cursor = newCursorValue;
  }
  var node = cursor.nodes[key.last];
  if (node == null) return null;
  if (node is YamlList) {
    return node.nodes.map((e) => e.span.text).join(",");
  } else {
    return node.span.text;
  }
}