getDirectorySize static method
Calculates the total size of all files in the given directory.
Recursively traverses the directory and sums up the size of all files. Directories themselves are not counted, only the files they contain.
Parameters:
directory: The directory to calculate the size for
Returns the total size in bytes as a double.
Implementation
static Future<double> getDirectorySize(Directory directory) async {
final files = directory.listSync(recursive: true);
double size = 0;
for (final file in files) {
if (file is File) {
size += file.lengthSync();
}
}
return size;
}