'ERROR : Undefined name 'Firebase' in main.dart
Hello to whom it may concern, I am setting up flutter environment in Android Studio and have searched to resolve this error but couldn't find any solution. The app I am working on has been registered with Firebase and I have copied all the code from flutter repo everything is fine except this one error where the keyword Firebase is not recognized. I have imported the targeted libraries but to no good.
Here is the line of code that has the error in main.dart:
await Firebase.initializeApp();
Your help would mean a lot! Thank you
Solution 1:[1]
Looks like you're missing firebase_core for some reason.
Try adding explicitly to your pubspec.yaml and see if it helps.
firebase_core: ^1.0.1
Solution 2:[2]
not to use- firebase_core: ^0.4.0+9 to use- firebase_core: ^1.4.0
not to use- firebase_analytics: ^5.0.2 to use- firebase_analytics: ^8.2.0
not to use- firebase_auth: ^0.14.0+5 to use- firebase_auth: ^3.0.1
not to use- cloud_firestore: ^0.12.9+5 to use- cloud_firestore: ^2.4.0
changing versions helped me...... dont use versions mentioned on firebase documentation, use it from pub.dev
Solution 3:[3]
Did you try importing firebase_core in main.dart import 'package:firebase_core/firebase_core.dart';
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Miguel Ruivo |
| Solution 2 | Kapil Kukkar |
| Solution 3 | Ronald Nyathi |
