isDirectory function

bool isDirectory(
  1. String path
)

Check if a path points to a directory.

Parameters:

  • path: The path to check

Returns true if the path exists and is a directory, false otherwise.

Example:

if (isDirectory('/path/to/directory')) {
  print('It\'s a directory');
}

Implementation

bool isDirectory(String path) {
  final fromType = FileSystemEntity.typeSync(path);
  return fromType == FileSystemEntityType.directory;
}