Vidura Marambe
Vidura Marambe

Reputation: 11

Flutter Error : No Firebase App ‘[DEFAULT]’ has been created – call Firebase.initializeApp()

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firestore.initializeApp();
  runApp(BookApp());
}

I used these codes but firestore is not recognized in main.dart I am using latest versions

  cloud_firestore: ^1.0.1
  firebase_core: ^1.0.1

Upvotes: 1

Views: 90

Answers (2)

quoci
quoci

Reputation: 3557

You need to intialize FlutterFire first by calling await Firebase.initializeApp(); before using any Firebase services.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  await Firestore.initializeApp();
  runApp(BookApp()
}

Upvotes: 1

shree bhagwat
shree bhagwat

Reputation: 490

Check for the following, if you have missed some steps:

Create a firebase project in the firebase console.

Make sure the bundleID of the app matches with the bundle ID of the project created in Console.

Android: Make sure you have copied the google-services.json file to the Android>app directory (copy item if needed)

iOS: Make sure you have copied the GoogleServices-Info.plist file to iOS>Runner directory.

try flutter clean and restart the app

Upvotes: 1

Related Questions