getTotalSizeOfFilesInDir static method

Future<double> getTotalSizeOfFilesInDir(
  1. FileSystemEntity file
)

Implementation

static Future<double> getTotalSizeOfFilesInDir(
   final FileSystemEntity file) async {
 if (file is File) {
   int length = await file.length();
   return double.parse(length.toString());
 }
 if (file is Directory) {
   final List<FileSystemEntity> children = file.listSync();
   double total = 0;
   if (children != null)
     for (final FileSystemEntity child in children)
       total += await getTotalSizeOfFilesInDir(child);
   return total;
 }
 return 0;
  }