簡體   English   中英

(flutter web) TypeError: Cannot read properties of undefined (reading 'auth')

[英](flutter web) TypeError: Cannot read properties of undefined (reading 'auth')

I have a flutter web project and I use firebase services, The project was working perfectly until I add the package "cloud_functions 3.3.7" , a problem appaired in firebase auth .

TypeError:無法讀取未定義的屬性(讀取'auth')

我試圖刪除 package "cloud_functions 3.3.7"問題仍然是一樣的。

我嘗試將這些包添加到 index.html 中。

<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-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-storage.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-messaging.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-analytics.js"></script>

它顯示了這個錯誤

FirebaseError: Firebase: firebase.auth() 不接受任何參數或 Firebase App 實例。 (應用程序/無效應用程序參數)。

代碼初始化 Firebase

await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
dependencies:
  firebase_core: ^1.13.1
  firebase_analytics: ^9.1.2
  firebase_auth: ^3.3.10
  cloud_firestore: ^3.1.10
  cloud_functions: ^3.3.7 
  firebase_storage: ^10.2.9

我創建了一個新項目 flutter 並替換了文件(lib,資產,..)並在pubspec.yaml中添加了包,它完美地工作並將其與 firebase 鏈接。

dart pub global activate flutterfire_cli
flutterfire configure --project=your_project_id

這不是一個完美的解決方案,但它仍然有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM