load method
Reads the pubspec.yaml
file and returns the content as a Map.
Throws a FileSystemException if the file does not exist. Throws a FormatException if the file is not a valid YAML file.
Implementation
Map<String, dynamic> load() {
final file = File(_filepath);
if (!file.existsSync()) {
throw FileSystemException('File $_filepath not found');
}
try {
final yamlString = file.readAsStringSync();
final yamlMap = loadYaml(yamlString) as YamlMap;
final pubspec = Map<String, dynamic>.from(yamlMap);
if (pubspec['inno_build'] == null) {
pubspec['inno_build'] = {};
save(pubspec);
}
return pubspec;
} catch (e) {
throw FormatException('Error reading or processing YAML file: $e');
}
}