Error: [core/not-initialized] Firebase has not been correctly initialized. Have you added the Firebase import scripts to your index.html file?

「Error: [core/not-initialized] Firebase has not been correctly initialized. Have you added the Firebase import scripts to your index.html file?」のアイキャッチ画像

flutterをwebで走らせたらタイトルのエラー発生

どうやらfirebaseをimportできていないことが問題っぽいので、

web/index.html にこちらを追記

<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-analytics.js"></script></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);
      firebase.analytics();
    </script>

これでいけました

参考記事

Web Installation