[英]How can I load a particular widget in Flutter?
当用户注册或登录时,会监听身份验证更改。退出 function 效果很好。 Home() 在用户注销时加载。 但是当用户登录/注册时,会打印消息“用户不为空”,但不会加载 HomeScreen() 小部件。 请帮忙。
class Wrapper extends StatelessWidget {
@override
Widget build(BuildContext context) {
final user = Provider.of<User>(context); // getting user from main.dart which gets the user from
stream
print(user);
print('here in wrapper');
if(user == null) // the user is logged out
{
print('User is null');
return Home();
}
else // user is registered or signed in
{
print('User is not null');
return HomeScreen();
}
} }
您使用 firebase 对吗? 执行注销 function 以处置当前用户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.