Home > front end >  FirebaseOptions cannot be null when creating the default app flutter
FirebaseOptions cannot be null when creating the default app flutter

Time:10-27

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

CodePudding user response:

You can reference the Flutter Firebase setup steps here: enter image description here

You will use DefaultFirebaseOptions.currentPlatform

  • Related