loadFromYamlString function

Future<Map<String, Object>> loadFromYamlString(
  1. String content
)

Implementation

Future<Map<String, Object>> loadFromYamlString(String content) async {
  try {
    final node = loadYamlNode(content);

    var optionsNode = node is YamlMap ? yamlMapToDartMap(node) : <String, Object>{};

    final includeNode = optionsNode['include'];
    if (includeNode is String) {
      final resolvedUri = await Isolate.resolvePackageUri(Uri.parse(includeNode));
      if (resolvedUri != null) {
        final resolvedYamlMap = await loadConfigFromYamlFile(File.fromUri(resolvedUri));
        optionsNode = _mergeMaps(resolvedYamlMap, optionsNode);
      }
    }

    return optionsNode;
  } on YamlException catch (e) {
    throw FormatException(e.message, e.span);
  }
}