loadFromAnalysisOptions static method
Implementation
static Settings loadFromAnalysisOptions([String? rootPath]) {
final file = File(
rootPath == null
? 'analysis_options.yaml'
: '$rootPath${Platform.pathSeparator}analysis_options.yaml',
);
if (!file.existsSync()) {
return const Settings();
}
final contents = file.readAsStringSync();
final yaml = loadYaml(contents);
final preferShorthands = yaml['prefer_shorthands'];
if (preferShorthands is! YamlMap) {
return const Settings();
}
return Settings(
convertImplicitDeclaration: preferShorthands.getKeyAsTypeOrNull<bool>(
'convert_implicit_declaration',
),
);
}