offline_storage_sync 0.0.1
offline_storage_sync: ^0.0.1 copied to clipboard
A package that helps developers manage offline data storage and synchronization with a backend service.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:offline_storage_sync/offline_storage_sync.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final localStorage = LocalStorage();
await localStorage.init();
final cacheStorage = CacheStorage();
await cacheStorage.init();
final syncService = SyncService(localStorage, cacheStorage, 'https://your-backend-url.com');
runApp(MyApp(syncService: syncService));
}
class MyApp extends StatelessWidget {
final SyncService syncService;
MyApp({required this.syncService});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Offline Storage Sync Example'),
),
body: Center(
child: ElevatedButton(
onPressed: () async {
final data = DataModel(id: 1, data: 'Sample Data');
await syncService.syncData();
},
child: Text('Sync Data'),
),
),
),
);
}
}