SyncMetadataStore class

Hive-backed persistence layer for SyncMetadata records.

Each sync-enabled entity type gets its own SyncMetadataStore backed by a Box<SyncMetadata>. This store tracks which local records need syncing, their current SyncStatus, retry counts, error messages, and tombstone markers for deletions.

Keys are entity identifiers (typically entity.id). The store keeps the domain entity pure — no sync infrastructure fields pollute it.

Example

final box = await Hive.openBox<SyncMetadata>('product_sync_meta');
final store = SyncMetadataStore(box);

// Mark a record as pending after local create
await store.put('42', SyncMetadata(
  status: SyncStatus.pending,
  operation: SyncOperation.create,
));

// Query pending records
final pendingKeys = await store.getKeysByStatus(SyncStatus.pending);

Constructors

SyncMetadataStore(Box<SyncMetadata> _box)

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() → Future<void>
Remove all sync metadata from the store.
countByStatus(SyncStatus status) → Future<int>
Count entries whose metadata matches the given status.
get(String key) → Future<SyncMetadata?>
Get sync metadata for key, or null if the key is not tracked.
getByKeys(Iterable<String> keys) → Future<Map<String, SyncMetadata>>
Snapshot metadata for keys in a single awaited call.
getKeysByStatus(SyncStatus status) → Future<List<String>>
Get all keys whose metadata matches the given status.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
put(String key, SyncMetadata metadata) → Future<void>
Insert or replace sync metadata for key.
putAll(Map<String, SyncMetadata> entries) → Future<void>
Insert or replace multiple metadata entries in a single box write.
remove(String key) → Future<void>
Remove sync metadata for key.
toString() → String
A string representation of this object.
inherited

Operators

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