[英]Update data from user in firebase flutter
I want to get the ID of a firebase object, but i can't think of a solution to store in a string variable, i only can reach here (witch is to get the id in a text widget form lmao)我想获取 firebase object 的 ID,但我想不出存储在字符串变量中的解决方案,我只能到达这里(女巫是在文本小部件形式 lmao 中获取 id)
static getUserDocId() {
return StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('users')
.where('idUser', isEqualTo: FirebaseAuth.instance.currentUser!.uid)
.snapshots(),
builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData) return Container();
return Text(
snapshot.data!.docs[0].id,
style: headline1,
);
},
);
}
Don't know if i have to change to futurebuilder or what.不知道我是否必须更改为futurebuilder或什么。
What do you mean by logged?登录是什么意思? and screen?和屏幕? are you using firebase auth?你在使用 firebase 身份验证吗? could use a little more explanation.可以使用更多的解释。
But If you want to update the firebase user document you will need to access the doc by its id.但是如果您想更新 firebase 用户文档,您将需要通过其 id 访问该文档。
await FirebaseFirestore.instance.collection('users').doc({document_id}).update(
{
'typeContact': _selectedContact,
'contact': _contactController.text,
},
)
Might find this page helpful https://firebase.flutter.dev/docs/firestore/usage#updating-documents可能会发现此页面有用https://firebase.flutter.dev/docs/firestore/usage#updating-documents
Please clarify the question.请澄清问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.