skip to Main Content

I am trying to run a flutter app locally on my web browser (chrome). I do the following steps:

flutter channel stable
flutter config --enable-web
flutter run -d chrome

when I run it, it starts fine, and opens chrome but it doesn’t load anything, and then throws this error:

"FirebaseOptions cannot be null when creating the default app."
at Object.throw_ [as throw] (http://localhost:63723/dart_sdk.js:5080:11)
at Object.assertFailed (http://localhost:63723/dart_sdk.js:5005:15)
at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:63723/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
at initializeApp.next (<anonymous>)
at http://localhost:63723/dart_sdk.js:40641:33
at _RootZone.runUnary (http://localhost:63723/dart_sdk.js:40511:59)
at _FutureListener.thenAwait.handleValue (http://localhost:63723/dart_sdk.js:35438:29)
at handleValueCallback (http://localhost:63723/dart_sdk.js:35999:49)
at _Future._propagateToListeners (http://localhost:63723/dart_sdk.js:36037:17)
at [_completeWithValue] (http://localhost:63723/dart_sdk.js:35872:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:63723/dart_sdk.js:35906:35)
at Object._microtaskLoop (http://localhost:63723/dart_sdk.js:40778:13)
at _startMicrotaskLoop (http://localhost:63723/dart_sdk.js:40784:13)
at http://localhost:63723/dart_sdk.js:36261:9

how would I fix this?

edit:

void main() async{


WidgetsFlutterBinding.ensureInitialized();
  setPathUrlStrategy();
  await Firebase.initializeApp();

2

Answers


  1. You can reference the Flutter Firebase setup steps here: https://firebase.google.com/docs/flutter/setup?platform=ios

    Specifically, make sure you don’t miss the following 2 steps:

    1. In the terminal, run flutterfire config
    2. In main.dart, make sure to add this code snippet:
    await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform,
    );
    

    As explained here, flutterfire config will auto-create a FirebaseOptions class for you.

    Login or Signup to reply.
  2. Start with firebase init command and follow this

    once you are done, you will get firebase_options.dart like t

    main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await Firebase.initializeApp(
        options: DefaultFirebaseOptions.currentPlatform,
      );
      runApp(YourApp());
    }
    

    enter image description here

    You will use DefaultFirebaseOptions.currentPlatform

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search