1
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

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.