Aroosa Khugyani
Aroosa Khugyani

Reputation: 1

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();

The error reads "Undefined name 'Firebase'. Try correcting the name to one that is defined, or defining the name"

Your help would mean a lot! Thank you

Upvotes: 0

Views: 3533

Answers (3)

Ronald Nyathi
Ronald Nyathi

Reputation: 11

Did you try importing firebase_core in main.dart import 'package:firebase_core/firebase_core.dart';

Upvotes: 1

Kapil Kukkar
Kapil Kukkar

Reputation: 1

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

Upvotes: 0

Miguel Ruivo
Miguel Ruivo

Reputation: 17756

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

Upvotes: 0

Related Questions