ContractsGeneratorConfig.fromYaml constructor
ContractsGeneratorConfig.fromYaml(
- String yaml
Implementation
factory ContractsGeneratorConfig.fromYaml(String yaml) {
final config = mergeMaps<dynamic, dynamic>(
loadYaml(defaultYamlConfig) as Map,
loadYaml(yaml) as Map,
);
final dynamic name = config['name'];
final dynamic include = config['include'];
final dynamic output = config['output'];
final dynamic directives = config['directives'];
final dynamic extra = config['extra'];
if (name is! String) {
throw ArgumentError('`name` field has to be a string');
}
if (include is! String) {
throw ArgumentError('`include` field has to be a string');
}
if (output is! String) {
throw ArgumentError('`output` field has to be a string');
}
if (directives is! String) {
throw ArgumentError('`directives` field has to be a string');
}
if (extra is! String) {
throw ArgumentError('`extra` field has to be a string');
}
return ContractsGeneratorConfig(
input: _configure(config),
name: name,
include: RegExp(include),
output: Directory(output),
directives: directives,
extra: extra,
);
}