readRawYaml static method

Map<String, dynamic> readRawYaml(
  1. File file
)

Reads a YAML file as a mutable JSON-compatible map.

Shared with the commands that rewrite the configuration, so they all treat an empty or non-mapping document the same way.

Implementation

static Map<String, dynamic> readRawYaml(File file) {
  final decoded = loadYaml(file.readAsStringSync());
  if (decoded is! Map) return <String, dynamic>{};
  return Map<String, dynamic>.from(jsonDecode(jsonEncode(decoded)) as Map);
}