Hello I am getting flutter firebase web error.
I initialized web properly but I am getting this error when I try to use firebase Firestore functions.
I have no idea about this error ….
Is there anyone who has this error before ?
Thangs for reading.
FirebaseError: Firebase: firebase.firestore() takes either no argument or a Firebase App instance.
(app/invalid-app-argument).
at Object.e [as firestore] (https://www.gstatic.com/firebasejs/8.10.1/firebase-app.js:1:19409)
at Object.getFirestoreInstance
(http://localhost:5000/packages/cloud_firestore_web/src/interop/utils/utils.dart.lib.js:1226:79)
at get [_delegate] (http://localhost:5000/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:778:59)
at cloud_firestore_web.FirebaseFirestoreWeb.new.doc
(http://localhost:5000/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:811:76)
at cloud_firestore.FirebaseFirestore.__.doc
(http://localhost:5000/packages/cloud_firestore/cloud_firestore.dart.lib.js:1456:84)
at database_service.DataBaseServcie.new.read
(http://localhost:5000/packages/root/img_files/img_slider.dart.lib.js:5997:65)
at read.next (<anonymous>)
at runBody (http://localhost:5000/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:5000/dart_sdk.js:40691:7)
at database_service.DataBaseServcie.new.read
(http://localhost:5000/packages/root/img_files/img_slider.dart.lib.js:5992:20)
at http://localhost:5000/packages/timetowork/screen/posting/posting_main_screen.dart.lib.js:15869:44
at [_handleTap] (http://localhost:5000/packages/flutter/src/material/icon_button.dart.lib.js:42254:31)
at tap.TapGestureRecognizer.new.invokeCallback
(http://localhost:5000/packages/flutter/src/gestures/recognizer.dart.lib.js:198:18)
at tap.TapGestureRecognizer.new.handleTapUp
(http://localhost:5000/packages/flutter/src/gestures/tap.dart.lib.js:411:42)
at [_checkUp] (http://localhost:5000/packages/flutter/src/gestures/tap.dart.lib.js:217:12)
at tap.TapGestureRecognizer.new.handlePrimaryPointer
(http://localhost:5000/packages/flutter/src/gestures/tap.dart.lib.js:166:23)
at tap.TapGestureRecognizer.new.handleEvent
(http://localhost:5000/packages/flutter/src/gestures/recognizer.dart.lib.js:444:16)
at [_dispatch] (http://localhost:5000/packages/flutter/src/gestures/pointer_router.dart.lib.js:86:9)
at http://localhost:5000/packages/flutter/src/gestures/pointer_router.dart.lib.js:112:26
at LinkedMap.new.forEach (http://localhost:5000/dart_sdk.js:27745:11)
at [_dispatchEventToRoutes]
(http://localhost:5000/packages/flutter/src/gestures/pointer_router.dart.lib.js:110:29)
at pointer_router.PointerRouter.new.route
(http://localhost:5000/packages/flutter/src/gestures/pointer_router.dart.lib.js:105:37)
at binding$5.WidgetsFlutterBinding.new.handleEvent
(http://localhost:5000/packages/flutter/src/gestures/binding.dart.lib.js:367:26)
at binding$5.WidgetsFlutterBinding.new.dispatchEvent
(http://localhost:5000/packages/flutter/src/gestures/binding.dart.lib.js:355:24)
at binding$5.WidgetsFlutterBinding.new.dispatchEvent
(http://localhost:5000/packages/flutter/src/rendering/layer.dart.lib.js:5440:13)
at [_handlePointerEventImmediately]
(http://localhost:5000/packages/flutter/src/gestures/binding.dart.lib.js:331:14)
at binding$5.WidgetsFlutterBinding.new.handlePointerEvent
(http://localhost:5000/packages/flutter/src/gestures/binding.dart.lib.js:305:43)
at [_flushPointerEventQueue] (http://localhost:5000/packages/flutter/src/gestures/binding.dart.lib.js:295:14)
at [_handlePointerDataPacket] (http://localhost:5000/packages/flutter/src/gestures/binding.dart.lib.js:286:54)
at Object.invoke1 (http://localhost:5000/dart_sdk.js:191747:7)
at _engine.EnginePlatformDispatcher.__.invokeOnPointerDataPacket (http://localhost:5000/dart_sdk.js:171943:15)
at [_onPointerData] (http://localhost:5000/dart_sdk.js:172879:49)
at http://localhost:5000/dart_sdk.js:173317:28
at http://localhost:5000/dart_sdk.js:173273:16
at loggedHandler (http://localhost:5000/dart_sdk.js:172978:11)
2
Answers
Try upgrading your packages at:
firebase_core: ^1.20.0
cloud_firestore: ^3.4.2
then flutter clean / flutter pub get
flutter pub upgrade --major-versions
dart fix --apply