FirebaseAnalytics.instanceFor constructor

FirebaseAnalytics.instanceFor({
  1. required FirebaseApp app,
  2. Map<String, dynamic>? webOptions,
})

Returns an instance using a specified FirebaseApp.

Note; multi-app support is only supported on web.

Implementation

factory FirebaseAnalytics.instanceFor({
  required FirebaseApp app,
  Map<String, dynamic>? webOptions,
}) {
  if (kIsWeb || app.name == defaultFirebaseAppName) {
    return _firebaseAnalyticsInstances.putIfAbsent(app.name, () {
      return FirebaseAnalytics._(app: app, webOptions: webOptions);
    });
  }

  throw PlatformException(
    code: 'default-app',
    message: 'Analytics has multi-app support for web only.',
  );
}