initialize static method
Implementation
static Firestore initialize(
String projectId, {
bool useApplicationDefaultAuth = false,
String? databaseId,
Emulator? emulator,
}) {
if (initialized) {
throw Exception('Firestore instance was already initialized');
}
final RequestAuthenticator? authenticator;
if (useApplicationDefaultAuth) {
authenticator = ApplicationDefaultAuthenticator(
useEmulator: emulator != null,
).authenticate;
} else {
FirebaseAuth? auth;
try {
auth = FirebaseAuth.instance;
} catch (e) {
// FirebaseAuth isn't initialized
}
authenticator = TokenAuthenticator.from(auth)?.authenticate;
}
_instance = Firestore(
projectId,
databaseId: databaseId,
authenticator: authenticator,
emulator: emulator,
);
return _instance!;
}