OfflineSyncManager class

The main manager class for offline synchronization functionality.

This class provides a high-level API for managing offline data storage and synchronization across all supported platforms.

Properties

connectivityStream Stream<bool>
Stream of connectivity status changes.
no setter
database OfflineDatabase
Gets the database instance for advanced usage.
no setter
hashCode int
The hash code for this object.
no setterinherited
isOnline bool
Checks if the device is currently online.
no setter
networkManager NetworkManager
Gets the network manager instance for advanced usage.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
status SyncStatus
Gets the current sync status.
no setter
statusStream Stream<SyncStatus>
Stream of sync status changes.
no setter
syncEngine SyncEngine
Gets the sync engine instance for advanced usage.
no setter

Methods

count(String tableName, {bool includeDeleted = false}) Future<int>
Counts entities in a table.
delete(String id, String tableName, {bool softDelete = true}) Future<void>
Deletes an entity from the local database.
dispose() Future<void>
Disposes of the offline sync manager.
findAll<T extends SyncEntity>(String tableName, {bool includeDeleted = false, int? limit, int? offset, String? orderBy, bool ascending = true}) Future<List<T>>
Finds all entities of a given type.
findById<T extends SyncEntity>(String id, String tableName) Future<T?>
Finds an entity by ID.
initialize({String? baseUrl, Map<String, String>? defaultHeaders, Duration? timeout, bool autoSyncEnabled = true, Duration? autoSyncInterval, int maxRetries = 3, int batchSize = 50}) Future<void>
Initializes the offline sync manager.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rawExecute(String sql, [List? arguments]) Future<int>
Executes a raw SQL command.
rawQuery(String sql, [List? arguments]) Future<List<Map<String, dynamic>>>
Executes a raw SQL query.
registerConflictResolver(String name, ConflictResolver resolver) → void
Registers a custom conflict resolver.
registerEntity<T extends SyncEntity>(String tableName, String endpoint, T fromJson(Map<String, dynamic>)) → void
Registers an entity type with the sync manager.
save<T extends SyncEntity>(T entity) Future<T>
Saves an entity to the local database.
setAutoSyncEnabled(bool enabled) → void
Enables or disables automatic synchronization.
setAutoSyncInterval(Duration interval) → void
Sets the auto-sync interval.
setBaseUrl(String baseUrl) → void
Sets the base URL for API requests.
setDefaultHeaders(Map<String, String> headers) → void
Sets default headers for all requests.
setMaxRetries(int maxRetries) → void
Sets the maximum number of retries for failed operations.
setTimeout(Duration timeout) → void
Sets the timeout for requests.
sync() Future<void>
Triggers a manual synchronization.
testConnection({String? testUrl}) Future<bool>
Tests the network connection.
toString() String
A string representation of this object.
inherited
transaction<T>(Future<T> action(dynamic txn)) Future<T>
Begins a database transaction.
update<T extends SyncEntity>(T entity) Future<T>
Updates an entity in the local database.

Operators

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

Static Properties

instance OfflineSyncManager
Gets the singleton instance of the offline sync manager.
no setter