user16234808
user16234808

Reputation:

Flutter problem when i try to run my App through Chrome(web), i get this errors

TypeError: Cannot read property 'app' of undefined at Object.app$ [as app] (http://localhost:53187/packages/firebase_core_web/src/interop/core.dart.lib.js:31:101) at new cloud_firestore_web.FirebaseFirestoreWeb.new (http://localhost:53187/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:773:64) at Function.registerWith (http://localhost:53187/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:692:73) at Object.registerPlugins (http://localhost:53187/packages/first_flutter_app/generated_plugin_registrant.dart.lib.js:16:46) at main (http://localhost:53187/web_entrypoint.dart.lib.js:31:35) at main.next () at runBody (http://localhost:53187/dart_sdk.js:37422:34) at Object._async [as async] (http://localhost:53187/dart_sdk.js:37453:7) at main$ (http://localhost:53187/web_entrypoint.dart.lib.js:30:18) at http://localhost:53187/main_module.bootstrap.js:19:10 at Array.forEach () at window.$dartRunMain (http://localhost:53187/main_module.bootstrap.js:18:32) at :1:8 at Object.runMain (http://localhost:53187/dwds/src/injected/client.js:8825:21) at http://localhost:53187/dwds/src/injected/client.js:22713:19 at _wrapJsFunctionForAsync_closure.$protected (http://localhost:53187/dwds/src/injected/client.js:3851:15) at _wrapJsFunctionForAsync_closure.call$2 (http://localhost:53187/dwds/src/injected/client.js:11063:12) at Object._asyncStartSync (http://localhost:53187/dwds/src/injected/client.js:3815:20) at main__closure1.$call$body$main__closure (http://localhost:53187/dwds/src/injected/client.js:22725:16) at main__closure1.call$1 (http://localhost:53187/dwds/src/injected/client.js:22652:19) at StaticClosure._rootRunUnary [as call$2$5] (http://localhost:53187/dwds/src/injected/client.js:4185:16) at _CustomZone.runUnary$2$2 (http://localhost:53187/dwds/src/injected/client.js:12436:39) at _CustomZone.runUnaryGuarded$1$2 (http://localhost:53187/dwds/src/injected/client.js:12383:14) at _ControllerSubscription._sendData$1 (http://localhost:53187/dwds/src/injected/client.js:11959:19) at _DelayedData.perform$1 (http://localhost:53187/dwds/src/injected/client.js:12148:59) at _PendingEvents_schedule_closure.call$0 (http://localhost:53187/dwds/src/injected/client.js:12197:14) at Object._microtaskLoop (http://localhost:53187/dwds/src/injected/client.js:4023:24) at StaticClosure._startMicrotaskLoop (http://localhost:53187/dwds/src/injected/client.js:4029:11) at _AsyncRun__initializeScheduleImmediate_internalCallback.call$1 (http://localhost:53187/dwds/src/injected/client.js:10932:9) at invokeClosure (http://localhost:53187/dwds/src/injected/client.js:1259:26) at MutationObserver. (http://localhost:53187/dwds/src/injected/client.js:1278:18)

And this is my pubspec.yaml file:

pubspec.yaml

Upvotes: 0

Views: 1396

Answers (1)

Mahendran K
Mahendran K

Reputation: 188

You're not initialize the firebase on the script file

Here Code:

  <html>
    <body>
      <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"> 
      </script>
      <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-functions.js">
      </script>
      <!-- Firebase Configuration -->
      <script>
        var firebaseConfig = {
        apiKey: "...",
        authDomain: "[YOUR_PROJECT].firebaseapp.com",
        databaseURL: "https://[YOUR_PROJECT].firebaseio.com",
        projectId: "[YOUR_PROJECT]",
        storageBucket: "[YOUR_PROJECT].appspot.com",
        messagingSenderId: "...",
        appId: "1:...:web:...",
        measurementId: "G-...",
        };

      // Initialize Firebase
      firebase.initializeApp(firebaseConfig);
     </script>
    </body>
  </html>

Adding this script on your index.html in your web directory.

Upvotes: 4

Related Questions