SyncConfig class

Configuration for SyncLayer initialization.

This class contains all the settings needed to configure SyncLayer's behavior, including backend connection, sync intervals, conflict resolution strategy, and which collections to sync.

Example:

final config = SyncConfig(
  baseUrl: 'https://api.example.com',
  authToken: 'your-auth-token',
  syncInterval: Duration(minutes: 5),
  maxRetries: 3,
  enableAutoSync: true,
  collections: ['todos', 'users', 'notes'],
  conflictStrategy: ConflictStrategy.lastWriteWins,
);

await SyncLayer.init(config);

Constructors

SyncConfig({String? baseUrl, String? authToken, Duration syncInterval = const Duration(minutes: 5), int maxRetries = 3, bool enableAutoSync = true, SyncBackendAdapter? customBackendAdapter, ConflictStrategy conflictStrategy = ConflictStrategy.lastWriteWins, CustomConflictResolverCallback? customConflictResolver, List<String> collections = const [], Map<String, SyncFilter> syncFilters = const {}, EncryptionConfig encryption = const EncryptionConfig.disabled(), bool enableRealtimeSync = false, String? websocketUrl, Duration websocketReconnectDelay = const Duration(seconds: 5), int maxWebsocketReconnectAttempts = 5})
const

Properties

authToken String?
Optional authentication token for backend requests.
final
baseUrl String?
The base URL of your backend API.
final
collections List<String>
List of collection names to sync with the backend.
final
conflictStrategy ConflictStrategy
Strategy for resolving conflicts when the same document is modified on multiple devices.
final
customBackendAdapter SyncBackendAdapter?
Optional custom backend adapter for non-REST backends.
final
customConflictResolver CustomConflictResolverCallback?
Custom conflict resolver function for advanced conflict resolution.
final
enableAutoSync bool
Whether to enable automatic background synchronization.
final
enableRealtimeSync bool
Enable real-time synchronization via WebSocket.
final
encryption EncryptionConfig
Encryption configuration for data at rest.
final
hashCode int
The hash code for this object.
no setterinherited
maxRetries int
Maximum number of retry attempts for failed sync operations.
final
maxWebsocketReconnectAttempts int
Maximum number of WebSocket reconnection attempts.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
syncFilters Map<String, SyncFilter>
Sync filters for selective synchronization per collection.
final
syncInterval Duration
How often to automatically sync with the backend.
final
websocketReconnectDelay Duration
Delay between WebSocket reconnection attempts.
final
websocketUrl String?
WebSocket server URL for real-time sync.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited