useFunctionsEmulator function

void useFunctionsEmulator(
  1. String origin, {
  2. String region = '',
  3. String? app,
})

Points one region's Functions at a local emulator. origin is a URL, not a host and port — the SDK takes it whole.

Each app and region keeps its own origin. A call by URL ignores it.

Implementation

void useFunctionsEmulator(String origin, {String region = '', String? app}) {
  final r = region.toNativeUtf8();
  final o = origin.toNativeUtf8();
  try {
    final rc = _onApp(
      app,
      (a) => fdbFunctionsUseEmulator(a, r.cast(), o.cast()),
    );
    if (rc != 0) {
      throw StateError(
        rc == -1
            ? 'useFunctionsEmulator before initFunctions${_forRegion(region)}'
            : 'useFunctionsEmulator failed ($rc)',
      );
    }
  } finally {
    calloc
      ..free(r)
      ..free(o);
  }
}