getTotalCacheSize static method

Future<int> getTotalCacheSize()

Get total cache size in bytes.

Implementation

static Future<int> getTotalCacheSize() async {
  final dir = Directory(await getCacheDir());
  if (!dir.existsSync()) return 0;

  int total = 0;
  await for (final entity in dir.list()) {
    if (entity is File) {
      total += entity.lengthSync();
    }
  }
  return total;
}