initializeApp method
Initializes a new FirebaseApp with the given name
and FirebaseOptions
.
Implementation
@override
Future<FirebaseApp> initializeApp({
String? name,
FirebaseOptions? options,
}) async {
assert(
options != null,
'options should be provided to initialize the default app.',
);
/// Ensures the name isn't null, in case no name
/// passed, [defaultFirebaseAppName] will be used
final _name = name ?? defaultFirebaseAppName;
try {
// Initialize the app in firebase_core_dart
final _dartOptions = core_dart.FirebaseOptions.fromMap(options!.asMap);
final _dartApp = await core_dart.Firebase.initializeApp(
name: _name,
options: _dartOptions,
);
return _mapDartToPlatfromApp(_dartApp);
} on core_dart.FirebaseException catch (e) {
switch (e.code) {
case 'no-app':
throw noAppExists(_name);
case 'duplicate-app':
throw duplicateApp(_name);
}
rethrow;
} catch (e) {
rethrow;
}
}