isDirEmpty function

bool isDirEmpty(
  1. Directory directory, {
  2. bool? isDirExist,
})

Checks if a directory is empty synchronously.

An empty directory contains no files or subdirectories.

Implementation

bool isDirEmpty(Directory directory, {bool? isDirExist}) {
  isDirExist ??= directory.existsSync();
  return isDirExist ? directory.listSync().isEmpty : false;
}