firestore library

Cloud Firestore, on the same firebase::App as initAuth and initDatabase.

Documents cross as CBOR in both directions. Firestore has value types CBOR has no native form for, so those travel as tagged items — see FirestoreValue for the mapping and why the tags are what they are.

Classes

FirestoreBatch
Buffered writes, applied atomically.
FirestoreGeoPoint
A latitude/longitude pair.
FirestoreReference
A reference to another document, by path.
FirestoreSentinel
An instruction to the server rather than a value.
FirestoreTag
Tag numbers shared with native/include/firebase_bridge.h.
FirestoreTimestamp
A point in time, to nanosecond precision.
FirestoreTransaction
The handle a transaction handler is given.
FirestoreValue
A Firestore value with no plain Dart equivalent.
OrderBy
An ordering clause.
QueryDocument
One document from a query: its body, and where it lives.
Where
A filter on a query. The operators are Firestore's own, spelled as the plugin spells them.

Properties

hasFirestore → bool
Whether this build binds Firestore.
no setter

Functions

averageCollection(String collectionPath, String field, {List<Where> where = const [], List<OrderBy> orderBy = const [], int? limit, int? limitToLast, bool collectionGroup = false}) → Future<double>
Averages field over what a query matches, computed by the server.
countCollection(String collectionPath, {List<Where> where = const [], List<OrderBy> orderBy = const [], int? limit, int? limitToLast, bool collectionGroup = false}) → Future<int>
Counts what a query matches, without fetching the documents.
decodeDocument(Uint8List bytes) → Map<String, Object?>?
Decodes a document from a snapshot buffer, or null when the payload is empty — which is how a missing document arrives.
decodeFirestoreValue(CborValue v) → Object?
The inverse: CBOR back to Dart, resolving the tagged types.
deleteDocument(String path) → Future<void>
Deletes path.
encodeFirestoreValue(Object? v) → CborValue
Encodes a document body for the native side.
getDocument(String path) → Future<Map<String, Object?>?>
Reads path, or null when it does not exist.
initFirestore() → void
onDocument(String path) → Stream<Map<String, Object?>?>
Watches path, emitting the document on every change and null when it does not exist. Canceling the subscription removes the listener.
onQuery(String collectionPath, {List<Where> where = const [], List<OrderBy> orderBy = const [], int? limit, int? limitToLast, List<Object?>? startAt, List<Object?>? startAfter, List<Object?>? endAt, List<Object?>? endBefore, bool collectionGroup = false}) → Stream<List<QueryDocument>>
Watches a query, emitting the whole result each time it changes.
queryCollection(String collectionPath, {List<Where> where = const [], List<OrderBy> orderBy = const [], int? limit, int? limitToLast, List<Object?>? startAt, List<Object?>? startAfter, List<Object?>? endAt, List<Object?>? endBefore, bool collectionGroup = false}) → Future<List<QueryDocument>>
Runs a query over collectionPath.
runTransaction(Future<void> handler(FirestoreTransaction tx)) → Future<void>
Runs handler in a transaction, retrying it if Firestore says to.
setDocument(String path, Map<String, Object?> data, {bool merge = false}) → Future<void>
Writes data to path. With merge, fields absent from data are left alone rather than removed.
sumCollection(String collectionPath, String field, {List<Where> where = const [], List<OrderBy> orderBy = const [], int? limit, int? limitToLast, bool collectionGroup = false}) → Future<double>
Sums field over what a query matches, computed by the server.
useFirestoreEmulator(String host, int port) → void
Creates the Firestore instance on the shared firebase::App.

Exceptions / Errors

FirestoreException
A Firestore operation that failed, carrying the SDK's own code and message.