Firebase is not getting initialized right

So, I wanted to include firebase into my Flutter App, it works fine for android but when I start it on my ios emulator it will always give me this error

[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized. Usually this means you've attempted to use a Firebase service before calling Firebase.initializeApp. View the documentation for more information: https://firebase.flutter.dev/docs/overview#initialization

I have the google-service file in the right directory and I followed the tutorial and edited my main() to:

    Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const MyApp());
}

Has anybody the same problem with IOS or did I do anything wrong?


So for everybody else getting this error I figured it out myself, for IOS, the line

  Firebase.initializeApp()

it needs an option:

Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform)

for that follow the instructions on this link:

https://firebase.flutter.dev/docs/cli

hope that helps anyone


  1. Install Firebase CLI if it is not installed in your system.
  2. Next, install the FlutterFire CLI or by running the following command:dart pub global activate flutterfire_cli. Once installed, the flutterfire command will be globally available.
  3. Run flutterfire configure in your flutter project folder in terminal,
  4. Select a Firebase project to configure your Flutter application with,
  5. Select/Insert android app id and bundle id you want to use as and when it asks you.
  6. and get firebase_options.dart.
  7. In main.dart file import firebase_options.dart.
  8. In void main() use following code.

        WidgetsFlutterBinding.ensureInitialized();
         if (Platform.isIOS) {
         await Firebase.initializeApp(
          options: DefaultFirebaseOptions.currentPlatform,
         );
           } else {
             await Firebase.initializeApp();
             }
        runApp(
        const MaterialApp(
        home: MyApp(),
        ),
      );