firestore property
FirebaseFirestore
get
firestore
The app-wide FirebaseFirestore instance, targeting
backendFirestoreDatabaseId (the (default) database when that is null).
Use this everywhere instead of FirebaseFirestore.instance so projects on
an Enterprise-edition NAMED database resolve to the correct database. The
emulator (when enabled) is configured on this same instance.
Implementation
static FirebaseFirestore get firestore {
if (!isFirebaseInitialized) {
throw StateError(
'Cannot access Firestore - Firebase is not initialized. '
'Call appInitFirebase() first.',
);
}
final dbId = backendFirestoreDatabaseId;
return (dbId == null || dbId.isEmpty)
? FirebaseFirestore.instanceFor(app: firebaseApp)
: FirebaseFirestore.instanceFor(app: firebaseApp, databaseId: dbId);
}