getTotalSizeOfFilesInDir static method
Implementation
static Future getTotalSizeOfFilesInDir(final FileSystemEntity file) async {
// File
if (file is File && file.existsSync()) {
int length = await file.length();
return double.parse(length.toString());
}
if (file is Directory && file.existsSync()) {
List children = file.listSync();
double total = 0.0;
if (children.isNotEmpty) {
for (final FileSystemEntity child in children) {
total += await getTotalSizeOfFilesInDir(child);
}
}
return total;
}
return 0.0;
}