ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: [core/duplicate-app] A Firebase App named "[DEFAULT]" already exists
Add this in Flutter
NOTE - Use this "Firebase.initializeApp" only Once in the entire Project.
// Wait for Default Firebase app to initialize
if (Firebase.apps.isEmpty) {
await Firebase.initializeApp(
name: 'YourAPP',
options: DefaultFirebaseOptions.currentPlatform,
).whenComplete(() {
print("completedAppInitialize");
});
}
I solved the issue by adding a name to the initializeApp method:
await Firebase.initializeApp(
name: 'name-here',
options: DefaultFirebaseOptions.currentPlatform,
)
I used the same name used in the firebase console as my project ID for consistency, keep in mind that you cannot add spaces to the name (only dashes -
).
flutter clean
and
flutter pub get
executing these two commands consecutively solved my problem.