offline_sync_kit 1.0.0 copy "offline_sync_kit: ^1.0.0" to clipboard
offline_sync_kit: ^1.0.0 copied to clipboard

Flutter package for offline data storage and synchronization with remote APIs.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:offline_sync_kit/offline_sync_kit.dart';
import 'models/todo.dart';
import 'screens/home_screen.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await initSyncManager();

  runApp(const MyApp());
}

Future<void> initSyncManager() async {
  // Put your API address here in a real application
  const baseUrl = 'https://jsonplaceholder.typicode.com';

  final storageService = StorageServiceImpl();
  await storageService.initialize();

  // Register model factory
  (storageService).registerModelDeserializer<Todo>(
    'todo',
    (json) => Todo.fromJson(json),
  );

  await OfflineSyncManager.initialize(
    baseUrl: baseUrl,
    storageService: storageService,
  );

  // Register Todo model with OfflineSyncManager
  OfflineSyncManager.instance.registerModelFactory<Todo>(
    'todo',
    (json) => Todo.fromJson(json),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Offline Sync Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const HomeScreen(),
    );
  }
}
7
likes
0
points
168
downloads

Publisher

verified publishercanarslan.me

Weekly Downloads

Flutter package for offline data storage and synchronization with remote APIs.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

connectivity_plus, equatable, flutter, http, intl, isar, isar_flutter_libs, path, path_provider, rxdart, sqflite, uuid

More

Packages that depend on offline_sync_kit