readYaml function
Reads the yamlFile
and returns a map of its contents.
The yamlFile
is passed as a File object instead of being hardcoded
because in the future, we may support reading multiple files for configuration.
Implementation
Map<String, dynamic> readYaml(File yamlFile) {
final yamlMap = (loadYaml(yamlFile.readAsStringSync()) ?? YamlMap()) as Map;
// yamlMap has the type YamlMap, which has several unwanted side effects
var json = yamlToMap(yamlMap as YamlMap);
return json;
}