Why it is showing error for DefaultFirebaseOptions.currentplatform?
I’m trying to connect flutter app to firebase and I implemented dependencies correctly,but showing error on DefaultFirebaseOptions.currentolatform.
Why it is showing error for DefaultFirebaseOptions.currentplatform?
I’m trying to connect flutter app to firebase and I implemented dependencies correctly,but showing error on DefaultFirebaseOptions.currentolatform.
2
Answers
I was facing the same issue after checking in the repository of Firebase. found that that has created a separated class for that you can take reference from here.
Hope it will work.
Reference github link
I just ran into the same problem. It happens if you use a tool (like following the Firebase setup instructions) that will automatically create
firebase_options.dart
for you. The tool creates it in{project_root}/lib/
right next to main.dart, but if you try to initialize Firebase in a different library like I did, it can’t findDefaultFirebaseOptions
.I had added the dependency for firebase_core in the library, but what I didn’t realize was that
DefaultFirebaseOptions
is actually defined in thefirebase_options.dart
file that is created and updated for you by theflutterfire configure
command. It’s a class with properties unique to your Firebase app.So, you can either add a dependency on the root project library to the .yaml for the sub project.
OR
Just initialize Firebase in the main.dart file like the documention mentions (but I initially took as only a suggestion).