getDartFiles function

Iterable<File> getDartFiles(
  1. Directory rootDir,
  2. String ignore
)

Returns all Dart files recursively from the rootDir.

Implementation

Iterable<File> getDartFiles(Directory rootDir, String ignore) {
  var dartFilesGlob = Glob('**.dart');
  var ignoreGlob = Glob(ignore, context: Context(current: rootDir.path));
  var alwaysIgnoreGlob =
      Glob(alwaysIgnore, context: Context(current: rootDir.path));

  var dartFiles = dartFilesGlob
      .listSync(root: rootDir.path, followLinks: false)
      .whereType<File>()
      .where((file) => !alwaysIgnoreGlob.matches(file.path))
      .where((file) => !ignoreGlob.matches(file.path));
  return dartFiles;
}