【发布时间】:2021-04-14 20:12:11
【问题描述】:
我正在尝试为 Firebase Auth 获取 UserProvider,但错误提示:
没有为“FirebaseAuth”类型定义 getter“AuthStateChanges”。
和
未定义名称“_onStateChanged”。
UserProvider.initialize() : _auth = FirebaseAuth.instance {
_auth.AuthStateChanges.listen(_onStateChanged);}
【问题讨论】:
-
身份验证状态更改参考 - firebase.flutter.dev/docs/auth/usage/#authentication-state。检查您是否有方法
_onStateChanged,您可以通过检查用户的状态来执行操作。 -
代码中的拼写略有偏差。它应该是
authStateChanges,以小写a开头。见pub.dev/documentation/firebase_auth/latest/firebase_auth/…
标签: firebase flutter firebase-authentication