useFirestoreEmulator method

void useFirestoreEmulator(
  1. String host,
  2. int port, {
  3. bool sslEnabled = false,
})

Points this instance at the Firestore emulator on host and port, as in FlutterFire: allowed until the instance is first used, like the settings setter. The same as setting settings.withEmulator(host, port), with sslEnabled off by default. Unlike FlutterFire, localhost is not mapped to 10.0.2.2 on the Android emulator: pass 10.0.2.2 yourself there.

FirebaseFirestore.instance.useFirestoreEmulator('127.0.0.1', 8080);

Throws a FirestoreException with FirestoreErrorCode.failedPrecondition once the instance was used, and an ArgumentError for the production host.

Implementation

void useFirestoreEmulator(String host, int port, {bool sslEnabled = false}) {
  _checkNotStarted('useFirestoreEmulator');
  final Settings emulated = _settings.withEmulator(host, port);
  _settings = sslEnabled ? emulated.copyWith(sslEnabled: true) : emulated;
}