FirestoreSyncSource class final
A SyncDataSource backed by Google Cloud Firestore.
Leverages Firestore's native offline persistence for additional resilience on top of Primekit's own offline-first layer.
Setup
- Add
firebase_coreandcloud_firestoreto yourpubspec.yaml. - Call
await Firebase.initializeApp()inmain(). - Pass a FirestoreSyncSource instance to SyncRepository.
final repo = SyncRepository<Todo>(
collection: 'todos',
remoteSource: FirestoreSyncSource(),
fromJson: Todo.fromJson,
);
User-scoped collections
When userId is provided to read/write methods, every document is
written under users/{userId}/{collection}/{documentId} so that
Firestore security rules can enforce row-level user isolation.
- Implemented types
Constructors
- FirestoreSyncSource({FirebaseFirestore? firestore, String timestampField = 'updatedAt'})
- Creates a FirestoreSyncSource.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- providerId → String
-
Identifies the backend provider.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timestampField → String
-
Firestore field name used for incremental fetch queries.
final
Methods
-
fetchChanges(
{required String collection, DateTime? since, String? userId}) → Future< List< Map< >String, dynamic> > -
Fetches all documents in
collectionthat have changed sincesince.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pushBatch(
{required String collection, required List< SyncChange> changes}) → Future<void> -
Pushes multiple changes to the remote backend in a single call.
override
-
pushChange(
{required String collection, required Map< String, dynamic> document, required SyncOperation operation}) → Future<void> -
Pushes a single document change to the remote backend.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
watchCollection(
{required String collection, String? userId}) → Stream< List< Map< >String, dynamic> > -
Opens a real-time stream of documents in
collection.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited