Flutter Web App, Firebase.auth not working. Tried to call a non-function, such as null. 'dart.global.firebase.auth'

后端 未结 1 1582
广开言路
广开言路 2021-01-22 21:24

I am trying to implement a simple Flutter Web App, with Firebase Auth.

I am getting the error NoSuchMethodError: tried to call a non-function, such as null: \'dart.

相关标签:
1条回答
  • 2021-01-22 21:34

    Turns out I placed this

    <!-- Firebase Configuration-->
      <!-- The core Firebase JS SDK is always required and must be listed first -->
      <script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-app.js"></script>
    
      <!-- TODO: Add SDKs for Firebase products that you want to use
          https://firebase.google.com/docs/web/setup#available-libraries -->
      <script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-auth.js"></script>
      <!-- <script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-analytics.js"></script>  -->
      <script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-app.js"></script>
      <script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-firestore.js"></script>
      <script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-storage.js"></script>
      <script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-database.js"></script>
    
      <script>
        // Your web app's Firebase configuration
        var firebaseConfig = {
          //my info
        };
        // Initialize Firebase
        firebase.initializeApp(firebaseConfig);
        // firebase.analytics();
      </script>
      <!-- End of Firebase Configuration-->
    

    In the wrong place.

    It should be inside the <head> tag.

    Side note, I had this <script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-app.js"></script> twice, so I deleted the one below.

    Finally, thanks to David Iglesias for his answer here: https://github.com/FirebaseExtended/flutterfire/issues/2860#issuecomment-651313186.

    0 讨论(0)
提交回复
热议问题