bedrock_sync library

BedrockSync — A backend-agnostic offline-first sync engine for Flutter.

Quick Start

import 'package:bedrock_sync/bedrock_sync.dart';

final engine = BedrockEngine(
  adapter: RestSyncAdapter(baseUrl: 'https://api.example.com'),
  config: SyncConfig(
    enableLogging: true,
    conflictResolver: LastWriteWinsResolver(),
  ),
);

await engine.init();

// Write locally (works offline)
await engine.write('todos', {'title': 'Buy milk', 'done': false});

// Read from local store
final todos = await engine.read('todos');

// Watch for real-time changes
engine.watch('todos').listen((todos) { setState(() => _todos = todos); });

// Manual sync
final result = await engine.sync();
print('Synced: ${result.syncedCount}');

Classes

BedrockEngine
The core sync engine.
ClientWinsResolver
───────────────────────────────────────────── Client Wins — local data always takes priority Best for: User settings, personal preferences ─────────────────────────────────────────────
ConflictResolver
Abstract base for all conflict resolution strategies.
ConnectivityMonitor
Monitors network connectivity and emits status changes.
CustomResolver
───────────────────────────────────────────── Custom Resolver — pass your own function Best for: Complex domain-specific rules ─────────────────────────────────────────────
FirebaseSyncAdapter
Firebase Firestore adapter stub.
LastWriteWinsResolver
───────────────────────────────────────────── Last Write Wins — whichever is most recent wins Best for: Notes, drafts, preferences ─────────────────────────────────────────────
LocalStore
Abstract interface for local storage.
MergeResolver
───────────────────────────────────────────── Merge Resolver — merges fields from both Server fields take priority on conflict unless overridden Best for: Documents, collaborative data ─────────────────────────────────────────────
RestSyncAdapter
A REST API sync adapter.
ServerWinsResolver
───────────────────────────────────────────── Server Wins — server data always takes priority Best for: Financial data, authoritative records ─────────────────────────────────────────────
SqfliteLocalStore
SQLite-backed local store using sqflite.
SupabaseSyncAdapter
Supabase adapter stub.
SyncAdapter
Abstract base class for all sync adapters.
SyncAdapterResult
Result of a SyncAdapter.push call
SyncConfig
Full configuration for BedrockSync.
SyncError
Details of a single sync failure
SyncOperation
Represents a single unit of work to be synced with the backend.
SyncQueue
Manages the persistent queue of pending SyncOperations.
SyncResult
Result of a sync() call
SyncStatus
Snapshot of the sync engine's current status

Enums

OperationStatus
Current status of a sync operation
OperationType
The type of CRUD operation being tracked
RetryStrategy
Defines retry backoff strategies for failed sync operations
SyncState
The current state of the sync engine
SyncTrigger
Defines when automatic sync should be triggered