[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: [core/duplicate-app] A Firebase App named “[DEFAULT]” already exists – Solved

To Solve this type of error in flutter , Just add “name” in Firebase.initializeApp(name : “MyApp”).

For example: –

Just change

await Firebase.initializeApp(
    // Replace with actual values
    options: const FirebaseOptions(
      apiKey: "<your apiKey>",
      appId: "<your appId>",
      messagingSenderId: "<messagingSenderId>",
      projectId: "<project-id>",
    ),
  )

To

await Firebase.initializeApp(
    name: "MyApp",
    // Replace with actual values
    options: const FirebaseOptions(
      apiKey: "<your apiKey>",
      appId: "<your appId>",
      messagingSenderId: "<messagingSenderId>",
      projectId: "<project-id>",
    ),
  )