When I try to launch my Flutter Web App with Firebase I get the following error in my terminal
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following FirebaseException was thrown building HomePage(dirty, dependencies: [MediaQuery]):
[core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()
The relevant error-causing widget was:
HomePage HomePage:file:///C:/Flutter/pbwebapp/lib/main.dart:37:13
When the exception was thrown, this was the stack:
...
I found other people had problems with this error but in my case I have called Firebase.initializeApp() in my main.dart
file and I have also imported firebase_core in my pubspec.yaml
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
name: "pbwebapp",
options: const FirebaseOptions(
apiKey: "...",
authDomain: "..",
projectId: "...",
storageBucket: "...",
messagingSenderId: "...",
appId: "...",
measurementId: "...",
),
);
runApp(MyApp());
}
Does anyone had this problem with Firebase trying to launch a Flutter Web App?
Thanks in advance!
2
Answers
Okay so somehow removing the name parameter in the
Firebase.initializeApp()
function worked for me. But I dont know why exactlyUse Flutter Fire Cli to add flutter firebase packages like auth, messaging etc,
It will automatically configure all the things for you.
https://firebase.google.com/docs/flutter/setup?platform=ios