app method

App? app([
  1. String appName = defaultAppName
])

Returns the FirebaseApp instance with the provided name (or the default FirebaseApp instance if no name is provided).

Implementation

App? app([String appName = defaultAppName]) {
  if (appName.isEmpty) {
    throw FirebaseAppError.invalidAppName(
      'Invalid Firebase app name "$appName" provided. App name must be a non-empty string.',
    );
  } else if (_apps[appName] == null) {
    var errorMessage = appName == defaultAppName
        ? 'The default Firebase app does not exist. '
        : 'Firebase app named "$appName" does not exist. ';
    errorMessage +=
        'Make sure you call initializeApp() before using any of the Firebase services.';

    throw FirebaseAppError.noApp(errorMessage);
  }

  return _apps[appName];
}