synclayer library
SyncLayer - Local-first sync SDK for Flutter
A powerful local-first synchronization engine that provides:
- Offline-first data storage with Isar
- Automatic sync when online
- Conflict resolution strategies
- Real-time data updates
- Backend adapters for Firebase, Supabase, Appwrite
Quick Start
import 'package:synclayer/synclayer.dart';
// Initialize
await SyncLayer.init(
SyncConfig(
baseUrl: 'https://api.example.com',
collections: ['todos'],
),
);
// Use it
final id = await SyncLayer.collection('todos').save({
'text': 'Buy milk',
'done': false,
});
See the README for more examples.
Classes
- CollectionReference
- Reference to a collection for performing CRUD operations.
- ConflictResolver
- Handles data conflicts during synchronization.
- ConflictResolvers
- Pre-built custom conflict resolvers for common scenarios.
- DeltaCalculator
- Calculates the difference between two document versions.
- DocumentDelta
- Represents a partial update (delta) to a document.
- EncryptionConfig
- Configuration for data encryption at rest.
- EncryptionService
- Service for encrypting and decrypting data.
- QueryBuilder
- Builder for constructing and executing queries on a collection
- SyncBackendAdapter
- Abstract interface for backend sync adapters This allows SyncLayer to work with different backends (REST, Firebase, Supabase, GraphQL)
- SyncConfig
- Configuration for SyncLayer initialization.
- SyncEvent
- Event emitted during sync operations.
- SyncFilter
- Sync filter for selective synchronization
- SyncLayer
- Main entry point for SyncLayer SDK.
- SyncLayerCore
- Core initialization and lifecycle manager for SyncLayer
- SyncLogger
- Logging utility for SyncLayer SDK
- SyncMetricEvent
- Metric event
- SyncMetrics
- Metrics and telemetry for SyncLayer SDK
- SyncMetricsSnapshot
- Metrics snapshot
- SyncRecord
- Sync record returned from backend
Enums
- ConflictStrategy
- Strategies for resolving conflicts when the same document is modified on multiple devices.
- EncryptionAlgorithm
- Encryption algorithms supported by SyncLayer.
- LogLevel
- Log levels for SyncLayer
- QueryOperator
- Query operators for filtering data
- SyncEventType
- Event types emitted during sync operations.
Typedefs
Exceptions / Errors
- EncryptionException
- Exception thrown when encryption/decryption fails.