Flutter 更新Firebase用户的用户信息
我试图在用户注册时更新显示名称和图像URL 我的程序流程是: 注册表(图像、用户名、电子邮件、密码)->验证电子邮件->验证后->将图像上载到firebase存储->获取URL->更新用户信息 数据已更新,我可以在控制台中看到它,但当我进入主屏幕时,它不会显示。我需要刷新应用程序,然后才能看到数据 我是不是遗漏了什么Flutter 更新Firebase用户的用户信息,flutter,Flutter,我试图在用户注册时更新显示名称和图像URL 我的程序流程是: 注册表(图像、用户名、电子邮件、密码)->验证电子邮件->验证后->将图像上载到firebase存储->获取URL->更新用户信息 数据已更新,我可以在控制台中看到它,但当我进入主屏幕时,它不会显示。我需要刷新应用程序,然后才能看到数据 我是不是遗漏了什么 if(_otpMatches) { FocusScope.of(context).requestFocus(new FocusNode()); Navigato
if(_otpMatches) {
FocusScope.of(context).requestFocus(new FocusNode());
Navigator.pop(context);
setState( () => loading = true);
//Sign Up user
Provider.of<AuthService>(context,listen: false)
.registerUser(_emailController.text,
_passwordController.text).whenComplete(() async {
print('username - ${_userNameController.text}');
User _user = FirebaseAuth.instance.currentUser;
//Upload user image
await storage.ref(fileName).putFile(
imageFile,
SettableMetadata(customMetadata: {
'uploaded_by': _userNameController.text,
'description': DateTime.now().toString()})
).whenComplete(() async {
_url = await FirebaseStorage.instance
.ref(fileName).getDownloadURL();
//Update User details
await _user.updateProfile(
displayName: _userNameController.text,
photoURL: _url).whenComplete(() {
});
});
}); }
return Scaffold(
backgroundColor: Colors.white,
body: ChangeNotifierProvider(
create: (context) => AuthService(),
child: StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context,snapshot) {
if(snapshot.hasData) {
return Home();
}
else
{
return Toggle();
}
}
),
),
);