【发布时间】:2019-12-03 19:33:33
【问题描述】:
当我在应用程序中按下“注销”时,currentUser 变为 null 但并没有真正注销应用程序,我正在使用 ScopedModel,如果我 print(model.isLoggedIn()) 返回 true,则表示存在某个用户在应用中,但用户为空。
当我按下退出时,我在输出时收到一条消息:
D/FirebaseAuth( 5252): Notifying id token listeners about a sign-out event.
D/FirebaseAuth( 5252): Notifying auth state listeners about a sign-out event.
D/FirebaseAuth( 5252): Notifying id token listeners about a sign-out event.
D/FirebaseAuth( 5252): Notifying auth state listeners about a sign-out event.
I/flutter ( 5252): true ( print in model.isLoggedIn() )
遵循退出代码
void signOut() async{
print(isLoggedIn());
await FirebaseAuth.instance.signOut();
userData = Map();
notifyListeners();
print(isLoggedIn());
}
bool isLoggedIn(){ return FirebaseUser != null; }
这是关于 UserModel 的完整代码: https://github.com/willsgobi/coleirapet/blob/master/lib/models/loginmodel.dart
【问题讨论】:
-
"currentUser 变为 null 但并没有真正退出应用程序" 你的意思是他们没有真正退出应用程序?
isLoggedIn是做什么的? -
“currentUser 变为 null 但并没有真正注销应用程序”:当我按下 Logout 时,currentUser 应该为 false,isLoggedIn 应该返回 false,但 isLoggedIn 之后返回 true,然后我调用函数 FirebaseUser .signOut(),表示auth有一些currentUser
-
函数 isLoggedIn 验证 FirebaseUser 是真还是假:``` bool isLoggedIn(){ return FirebaseUser != null; } ```
-
在下面回答,但请在以后的问题中确保minimal, complete/standalone code that is needed to reproduce the problem is present in your question itself。我建议研究该链接,因为它是提高获得代码相关问题帮助机会的最佳方式。
标签: firebase flutter firebase-authentication flutter-scoped-model