getDartFiles static method

List<File> getDartFiles(
  1. Directory directory
)

Retrieves all Dart files from a given directory.

This method scans the specified directory and its subdirectories for all .dart files and returns them as a list of File objects.

directory The directory to scan for Dart files.

Returns a list of File objects representing all Dart files in the directory.

Implementation

static List<File> getDartFiles(Directory directory) {
  return directory
      .listSync(
          recursive: true) // Recursively lists all files in the directory
      .where((entity) =>
          entity is File &&
          entity.path.endsWith('.dart')) // Filters out non-Dart files
      .cast<File>() // Casts the entity to a File type
      .toList(); // Converts to a list and returns it
}