FirebaseFirestoreFake class
An empty shell of a FirebaseFirestore
that can be used for testing or
creating an app that does not require a real connection to Firestore
The Stateful version of this class maintains its own state and aims to mimic Firestore, while the Stateless version allows you to compose the functionality and store the state outside of the class.
You can use this as a mock or a fake. If you want to use this as a mock, avoid the Stateful constructors, and return the expected values by passing them through the constructor
- Implemented types
-
- FirebasePluginPlatform
Constructors
-
FirebaseFirestoreFake({CollectionReference<
Map< collection(String name)?})String, dynamic> > -
FirebaseFirestoreFake.stateful({Map<
String, CollectionReferenceFake> ? collections, void onCollectionChanged(String path, Map<String, DocumentReferenceFake> collectionDocuments, List<QueryFakeAndStreamController> queries)?}) -
Creates a stateful FirebaseFirestore fake that maintains its own state and
aims to mimic firebase as closely as possible
factory
Properties
- app ↔ FirebaseApp
-
The
FirebaseApp
for this currentFirebaseFirestore
instance.getter/setter pairoverride - databaseId ↔ String
-
Firestore Database ID for this instance. Falls back to default database: "(default)"
getter/setter pairinherited
- databaseURL ↔ String
-
Firestore Database ID for this instance. Falls back to default database: "(default)"
This is deprecated in favor of
databaseId
.getter/setter pairinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- pluginConstants → Map
-
Returns any plugin constants this plugin app instance has initialized.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- settings ↔ Settings
-
The current
Settings
for thisFirebaseFirestore
instance.getter/setter pairoverride
Methods
-
batch(
) → WriteBatch -
Returns a
WriteBatch
, used for performing multiple writes as a single atomic operation.override -
clearPersistence(
) → Future< void> -
Clears any persisted data for the current instance.
override
-
collection(
String collectionPath) → CollectionReference< Map< String, dynamic> > -
Gets a
CollectionReference
for the specified Firestore path.override -
collectionGroup(
String collectionPath) → Query< Map< String, dynamic> > -
Gets a
Query
for the specified collection group.override -
disableNetwork(
) → Future< void> -
Instructs
FirebaseFirestore
to disable the network for the instance.override -
doc(
String documentPath) → DocumentReference< Map< String, dynamic> > -
Gets a
DocumentReference
for the specified Firestore path.override -
enableNetwork(
) → Future< void> -
Enables the network for this instance. Any pending local-only writes
will be written to the remote servers.
override
-
enablePersistence(
[PersistenceSettings? persistenceSettings]) → Future< void> -
Enable persistence of Firestore data for web-only. Use
Settings.persistenceEnabled
for non-web platforms. IfenablePersistence()
is not called, it defaults to Memory cache. IfenablePersistence(const PersistenceSettings(synchronizeTabs: false))
is called, it persists data for a single browser tab. IfenablePersistence(const PersistenceSettings(synchronizeTabs: true))
is called, it persists data across multiple browser tabs.override -
loadBundle(
Uint8List bundle) → LoadBundleTask -
override
-
namedQueryGet(
String name, {GetOptions options = const GetOptions()}) → Future< QuerySnapshot< Map< >String, dynamic> > -
Reads a
QuerySnapshot
if a namedQuery has been retrieved and passed as aBuffer
to loadBundle(). To read from cache, passGetOptions.source
value asSource.cache
. To read from the Firestore backend, useGetOptions.source
asSource.server
.override -
namedQueryWithConverterGet<
T> (String name, {GetOptions options = const GetOptions(), required FromFirestore< T> fromFirestore, required ToFirestore<T> toFirestore}) → Future<QuerySnapshot< T> > -
Performs a namedQueryGet and decode the result using
Query.withConverter
.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
runTransaction<
T> (TransactionHandler< T> transactionHandler, {Duration timeout = const Duration(seconds: 30), int maxAttempts = 5}) → Future<T> -
Executes the given
TransactionHandler
and then attempts to commit the changes applied within an atomic transaction.override -
setIndexConfiguration(
{required List< Index> indexes, List<FieldOverrides> ? fieldOverrides}) → Future<void> -
Configures indexing for local query execution. Any previous index configuration is overridden.
override
-
setIndexConfigurationFromJSON(
String json) → Future< void> -
Configures indexing for local query execution. Any previous index configuration is overridden.
override
-
snapshotsInSync(
) → Stream< void> -
Returns a Stream which is called each time all of the active listeners
have been synchronized.
override
-
terminate(
) → Future< void> -
Terminates this
FirebaseFirestore
instance.override -
toString(
) → String -
A string representation of this object.
inherited
-
useFirestoreEmulator(
String host, int port, {bool sslEnabled = false}) → void -
Changes this instance to point to a FirebaseFirestore emulator running locally.
override
-
waitForPendingWrites(
) → Future< void> -
Waits until all currently pending writes for the active user have been
acknowledged by the backend.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited