getStorageInfo static method
Get storage statistics
Implementation
static Future<StorageStats> getStorageInfo({
List<String>? protectedFiles,
}) async {
final directory = await getApplicationDocumentsDirectory();
final files = directory
.listSync()
.whereType<File>()
.where((file) => supportedExtensions.any((ext) => file.path.endsWith(ext)))
.toList();
int totalSize = 0;
for (final file in files) {
final stat = await file.stat();
totalSize += stat.size;
}
final orphaned = await getOrphanedFiles(protectedFiles: protectedFiles);
return StorageStats(
totalFiles: files.length,
totalSizeBytes: totalSize,
orphanedFiles: orphaned,
);
}