close

[Solved] FirebaseOptions cannot be null when creating the default app

Hello Guys How are you all? Hope You all are fine. I am using Firebase in my flutter app, But I am facing following error while initializeApp But I am facing following error FirebaseOptions cannot be null when creating the default app in a flutter. So today Here I come with all possible solutions for this error.

We are providing you all possible solutions to solve this error. let’s start this article without wasting your time.

How FirebaseOptions cannot be null when creating the default app Error Occurs ?

I am using Firebase in my flutter app, But I am facing following error while initializeApp But I am facing following error.

FirebaseOptions cannot be null when creating the default app.

How to Solve FirebaseOptions cannot be null when creating the default app Error?

  1. FirebaseOptions cannot be null when creating the default app

    To Solve FirebaseOptions cannot be null when creating the default app Error First Of all You need to use firebase_core this plugin. Add This line in your pubspec.yaml file. Then, get dependencies by flutter get. Now, Use FirebaseOptions in this way Now, Just Rerun Your App. And your error must be solved.

  2. How to Solve FirebaseOptions cannot be null when creating the default app Error?

    To Solve FirebaseOptions cannot be null when creating the default app Error First Of all You need to use firebase_core this plugin. Add This line in your pubspec.yaml file. Then, get dependencies by flutter get. Now, Use FirebaseOptions in this way Now, Just Rerun Your App. And your error must be solved.

Solution 1: Use FirebaseOptions

First Of all You need to use firebase_core this plugin. Add This line in your pubspec.yaml file.

dependencies:
  firebase_core: ^1.10.5

Then, get dependencies by flutter get. Now, Use FirebaseOptions in this way

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(

    options: FirebaseOptions(
      apiKey: "XXX", // Your apiKey
      appId: "XXX", // Your appId
      messagingSenderId: "XXX", // Your messagingSenderId
      projectId: "XXX", // Your projectId
    ),
  );
  runApp(MyApp());
}

Now, Just Rerun Your App. And your error must be solved.

Summery

So, It’s All About This Error. I hope this tutorial helps you to Solve your error. Please Comment Below if You stucks anywhere with my code. And please comment below on which solution worked for you. Thank You.

Also Check Out Below Tutorials

3 thoughts on “[Solved] FirebaseOptions cannot be null when creating the default app”

Leave a Comment