FirebaseAnalytics.instanceFor constructor

FirebaseAnalytics.instanceFor({
  1. required FirebaseApp app,
})

Returns an instance using a specified FirebaseApp.

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

Implementation

factory FirebaseAnalytics.instanceFor({required FirebaseApp app}) {
  if (kIsWeb || app.name == defaultFirebaseAppName) {
    return _firebaseAnalyticsInstances.putIfAbsent(app.name, () {
      return FirebaseAnalytics._(app: app);
    });
  }

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