I am building a flutter app with firebase. The firebase services I am using are Realtime database and Authentication. The app is normally starting as usual without throwing any exception, but while I am hot restarting the app, the app freezes throwing the following exception:
Unhandled Exception: [core/duplicate-app] A Firebase App named "db2" already exists
I believe there's something wrong with initializing FirebaseApp. The initialization code in main.dart reads:
WidgetsFlutterBinding.ensureInitialized();
final FirebaseApp app = await Firebase.initializeApp(
name: 'db2',
Can somebody help me solve this issue? Thank you!
I have two apps in firebase.One is Android and another one is web . So Initialize firebase instance like this
const firebaseConfig = FirebaseOptions(
apiKey: "AIzaSyA1S7r-kyTOCLWttcf4kC3Qye0s-gl96Ec",
appId: "1:390108250565:web:9821516ca39ba976358bac",
messagingSenderId: "390108250565",
projectId: "doc-appointment-aa751",
);
if(kIsWeb){
await Firebase.initializeApp(
options: firebaseConfig,
);
}else{
await Firebase.initializeApp();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With