How to solve: TypeError: Cannot read properties of undefined (reading 'app')

Question

Asked by Nathan on November 28, 2021 (source).

So I am following a tutorial on creating a quiz app in flutter and I keep getting this error below when I run it. Here is my full code so far: https://github.com/NathanDevelops1/quizappmaker.

This is the error:

    at Object.app$ [as app] (http://localhost:57087/packages/firebase/src/top_level.dart.lib.js:83:56)
    at new cloud_firestore_web.FirestoreWeb.new (http://localhost:57087/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:806:57)
    at Function.registerWith (http://localhost:57087/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:751:71)
    at Object.registerPlugins (http://localhost:57087/packages/quizappmaker/generated_plugin_registrant.dart.lib.js:18:38)
    at main (http://localhost:57087/web_entrypoint.dart.lib.js:31:35)
    at main.next (<anonymous>)
    at runBody (http://localhost:57087/dart_sdk.js:39250:34)
    at Object._async [as async] (http://localhost:57087/dart_sdk.js:39281:7)
    at main$ (http://localhost:57087/web_entrypoint.dart.lib.js:30:18)
    at http://localhost:57087/main_module.bootstrap.js:19:10
    at Array.forEach (<anonymous>)
    at window.$dartRunMain (http://localhost:57087/main_module.bootstrap.js:18:32)
    at <anonymous>:1:8
    at Object.runMain (http://localhost:57087/dwds/src/injected/client.js:8825:21)
    at http://localhost:57087/dwds/src/injected/client.js:22713:19
    at _wrapJsFunctionForAsync_closure.$protected (http://localhost:57087/dwds/src/injected/client.js:3851:15)
    at _wrapJsFunctionForAsync_closure.call$2 (http://localhost:57087/dwds/src/injected/client.js:11063:12)
    at Object._asyncStartSync (http://localhost:57087/dwds/src/injected/client.js:3815:20)
    at main__closure1.$call$body$main__closure (http://localhost:57087/dwds/src/injected/client.js:22725:16)
    at main__closure1.call$1 (http://localhost:57087/dwds/src/injected/client.js:22652:19)
    at StaticClosure._rootRunUnary [as call$2$5] (http://localhost:57087/dwds/src/injected/client.js:4185:16)
    at _CustomZone.runUnary$2$2 (http://localhost:57087/dwds/src/injected/client.js:12436:39)
    at _CustomZone.runUnaryGuarded$1$2 (http://localhost:57087/dwds/src/injected/client.js:12383:14)
    at _ControllerSubscription._sendData$1 (http://localhost:57087/dwds/src/injected/client.js:11959:19)
    at _DelayedData.perform$1 (http://localhost:57087/dwds/src/injected/client.js:12148:59)
    at _PendingEvents_schedule_closure.call$0 (http://localhost:57087/dwds/src/injected/client.js:12197:14)
    at Object._microtaskLoop (http://localhost:57087/dwds/src/injected/client.js:4023:24)
    at StaticClosure._startMicrotaskLoop (http://localhost:57087/dwds/src/injected/client.js:4029:11)
    at _AsyncRun__initializeScheduleImmediate_internalCallback.call$1 (http://localhost:57087/dwds/src/injected/client.js:10932:9)
    at invokeClosure (http://localhost:57087/dwds/src/injected/client.js:1259:26)
    at MutationObserver.<anonymous> (http://localhost:57087/dwds/src/injected/client.js:1278:18)

Answer

Question answered by Gokul N (source).

Please import firebase dependencies in your index.html:

<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js" />

Refer here.

ANDROID FLUTTER
SHARE: