loadFileYaml static method
Loads and parses a YAML file.
This method reads a YAML file and parses its contents into a Map. If an error occurs during reading or parsing, it prints an error message and returns an empty map.
Parameters:
path: The path to the YAML file to load
Returns: A Map containing the parsed YAML contents, or an empty map if an error occurs
Example:
final config = YamlHelper.loadFileYaml('./morpheme.yaml');
final appName = config['app_name'];
print('App name: $appName');
Implementation
static Map<dynamic, dynamic> loadFileYaml(String path) {
try {
final File file = File(path);
final String yamlString = file.readAsStringSync();
return loadYaml(yamlString);
} catch (e) {
printerrMessage(e.toString());
return {};
}
}