๐Ÿง  offline_sync_cache

A simple and lightweight offline-first caching utility for Dart & Flutter apps.
It automatically handles memory cache, disk cache, and network fetch with expiry control.


๐Ÿš€ Features

  • ๐Ÿง  In-memory caching for instant reads
  • ๐Ÿ’พ Disk persistence for offline access
  • ๐ŸŒ Auto-refresh via fetcher callback
  • โฐ Custom expiry duration
  • ๐Ÿงน Simple clear() to reset cache

๐Ÿ› ๏ธ Installation

Add this line to your pubspec.yaml:

dependencies:
  offline_sync_cache: ^1.0.0

## Usage

import 'package:offline_sync_cache/offline_sync_cache.dart';

void main() async {
  final cache = SmartCache();

  // Try to read data from cache, otherwise fetch from API
  final user = await cache.read('user', fetcher: () async {
    print('Fetching from API...');
    return {'name': 'Nget Sophun', 'age': 25};
  });

  print('Cached user: $user');
}

Libraries

offline_sync_cache