getCacheSize method

Future<int> getCacheSize()

Get cache size in bytes

Implementation

Future<int> getCacheSize() async {
  final cacheDirObj = Directory(cacheDir);
  if (!await cacheDirObj.exists()) {
    return 0;
  }

  int totalSize = 0;
  await for (final entity in cacheDirObj.list(recursive: true)) {
    if (entity is File) {
      totalSize += await entity.length();
    }
  }

  return totalSize;
}