loadFromYaml static method

AnalysisOptions loadFromYaml(
  1. String root,
  2. String yamlSource
)

Parses yamlSource, the contents of an analysis_options.yaml located in the directory root. Globs are matched relative to root.

Implementation

static AnalysisOptions loadFromYaml(String root, String yamlSource) {
  final yaml = json.decode(json.encode(loadYaml(yamlSource)));
  if (yaml is! Map<String, dynamic>) {
    return AnalysisOptions.empty(root);
  }
  final options = yaml['string_literal_finder'] as Map<String, dynamic>?;
  final excludeGlobs =
      options?['exclude_globs'] as List<dynamic>? ?? <dynamic>[];
  final debug = options?['debug'] as bool? ?? false;
  return AnalysisOptions(
    root: root,
    excludeGlobs: excludeGlobs.cast<String>().map(Glob.new).toList(),
    debug: debug,
  );
}