discontinuedPackage app_cache_manager has been discontinued.

App Cache Manager

A Flutter package for managing application cache efficiently. This package provides methods to check cache existence, calculate total cache size, and clear the cache. It is designed to simplify cache management, especially for file system caching.

Features

  • Check if cache exists
  • Calculate total cache size
  • Clear cache

Installation

To use this package, add app_cache_manager as a dependency in your pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter
  app_cache_manager: ^0.2.3  # Use the latest version

Then run the following command to fetch the package:

flutter pub get

Usage

                         *****

import 'package:app_cache_manager/app_cache_manager.dart';

 class _ExampleState extends State<Example> {
   String cacheSize = '';
   late final CacheManager cacheManager;

   @override
   void initState() {
    super.initState();
     cacheManager = CacheManager();
     updateCacheSize();
   }

   @override
   void didUpdateWidget(Settings oldWidget) {
     super.didUpdateWidget(oldWidget);
     updateCacheSize();
   }

   @override
   Widget build(BuildContext context) {
     return Scaffold(
       body: ListTile(
       trailing:Text(cacheSize),
       onTap: () async {
             cacheManager.clearCache();
             updateCacheSize();
         },
     ),
 );

  void updateCacheSize() async {
     String newSize = await cacheManager.getTotalCacheSize();
     setState(() => cacheSize = newSize);
   }
 }

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Additional information

This package provides a unified way to manage cache in Flutter applications across both Android and iOS platforms. The cache management is achieved through a combination of Flutter and native code.

Android Cache Management

Android cache management is handled entirely within the Flutter environment. The package leverages the getTemporaryDirectory method from the path_provider package to access and manage the Android cache directory. The methods provided by the package are platform-agnostic and work seamlessly on Android.

iOS Cache Management

For iOS cache management, native Swift code is used to interact with the cache system. The package includes a Swift bridge that communicates with the Flutter environment through method channels. This approach ensures efficient and accurate cache management on iOS devices.

Libraries

app_cache_manager
app_cache_manager: Flutter Package for Managing Application Cache