๐ง 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');
}