I am trying to initialize Firebase in flutter project. I use FutureBuilder to load this function:
static Future initializeFirebase({required BuildContext context}) async {
try {
FirebaseApp firebaseApp = await Firebase.initializeApp(
options: FirebaseOptions(
apiKey: "abc",
authDomain: "def",
projectId: "ghi",
storageBucket: "jkl",
messagingSenderId: "mno",
appId: "pqr",
measurementId: "stu"));
return firebaseApp;
} catch (err) {
print("ERRRRR $err");
throw err.toString();
}
}
when running in android and ios, it goes fine (nothing wrong), but whenever I run it in chrome it always throw Expected a value of type 'String', but got one of type 'Null'
is there a way to solve this
2
Answers
It seems you’re missing the databaseUrl in your config.
Well, there is an awesome way to connect your application to the Firebase using Flutterfire config I’ll share the link to the documentation and after a successful installation by running Flutterfire config you can easily configure the Firebase to your code.
Link: https://firebase.flutter.dev/docs/cli/
https://firebase.google.com/docs/flutter/setup?platform=android
This could take some data