writeMatchersToFile method

void writeMatchersToFile({
  1. required String path,
  2. Map<String, String> propNameOverrides = const {},
  3. String? imports,
  4. bool filter(
    1. DiagnosticsNode node
    )?,
})

Writes the generated matchers for the properties of W to a file.

Implementation

void writeMatchersToFile({
  required String path,
  Map<String, String> propNameOverrides = const {},
  String? imports,
  bool Function(DiagnosticsNode node)? filter,
}) {
  final content = createMatcherString(
    propNameOverrides: propNameOverrides,
    imports: imports,
    filter: filter,
  );
  final file = File(path);
  if (content == null) {
    if (file.existsSync()) {
      file.deleteSync();
    }
  } else {
    file
      ..createSync(recursive: true)
      ..writeAsStringSync(content);
  }
}