flutter_sync_client 0.1.1 copy "flutter_sync_client: ^0.1.1" to clipboard
flutter_sync_client: ^0.1.1 copied to clipboard

Real-time data synchronization plugin for Flutter with Hive and Socket.IO

Flutter Sync Client #

Real-time data synchronization plugin for Flutter with Hive and Socket.IO.

Installation #

Add to your pubspec.yaml:

dependencies:
  flutter_sync_client:
    path: ../flutter_sync_client

Usage #

1. Initialize Client #

final syncClient = SyncClient(
  serverUrl: 'http://your-server.com:3000',
);
await syncClient.initialize();

2. Get Collection Reference #

final todosCollection = syncClient.collection('todos');

3. Listen to Changes #

StreamBuilder<List<Map<String, dynamic>>>(
  stream: todosCollection.stream,
  builder: (context, snapshot) {
    final todos = snapshot.data ?? [];
    return ListView.builder(
      itemCount: todos.length,
      itemBuilder: (context, index) {
        return ListTile(title: Text(todos[index]['title']));
      },
    );
  },
)

4. CRUD Operations #

// Add
await todosCollection.add({
  'title': 'Buy milk',
  'completed': false,
});

// Update
await todosCollection.update(id, {
  'completed': true,
});

// Delete
await todosCollection.delete(id);

// Get single item
final todo = await todosCollection.get(id);

// Get all items
final todos = await todosCollection.getAll();

5. Connection Status #

StreamBuilder<bool>(
  stream: syncClient.connectionStream,
  builder: (context, snapshot) {
    final isConnected = snapshot.data ?? false;
    return Icon(
      isConnected ? Icons.cloud_done : Icons.cloud_off,
    );
  },
)

Features #

  • ✅ Real-time synchronization
  • ✅ Offline support with Hive
  • ✅ Automatic reconnection
  • ✅ Conflict resolution
  • ✅ Change listeners (Streams)
  • ✅ Energy efficient
  • ✅ Simple API

Example #

See the example directory for a complete Todo app.

Testing #

cd example
flutter run

Try:

  • Add todos
  • Toggle completion
  • Delete todos
  • Close app and reopen (data persists)
  • Stop server and make changes (offline mode)
  • Restart server (auto sync)

License #

MIT

0
likes
0
points
413
downloads

Publisher

unverified uploader

Weekly Downloads

Real-time data synchronization plugin for Flutter with Hive and Socket.IO

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

connectivity_plus, flutter, hive, hive_flutter, plugin_platform_interface, socket_io_client, uuid

More

Packages that depend on flutter_sync_client

Packages that implement flutter_sync_client