【发布时间】:2021-09-08 18:47:06
【问题描述】:
这是我的 Firestore 数据库的屏幕截图 文档 ID 以用户 uid 命名。
下面是我目前的代码
Widget _inputEmail() {
return StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
stream: FirebaseFirestore.instance
.collection("users")
.snapshots(),
builder: (context, snapshot) {
return Container(
width: 355,
padding: EdgeInsets.only(bottom: 20),
child: TextFormField(
controller: _email,
decoration: InputDecoration(
hintText: 'Email',
helperText: 'Enter Email',
suffixIcon: IconButton(
icon: Icon(Icons.navigate_next),
onPressed: () {
FirebaseFirestore.instance
.collection('users')
.where('email', isEqualTo: _email)
.get()
.then((snapshot) => print(snapshot.docs[0].data()['user.uid']));
},
),
border: UnderlineInputBorder()),
),
);
}
);
我想要实现的是,当用户输入电子邮件时,在此文本字段中,它将显示该电子邮件所在位置的文档 ID,以便我可以创建另一个函数来修改货币数据。
应用截图
基本上这将是一个转账菜单,其中输入的电子邮件是收件人的电子邮件,按下按钮后,用户可以输入他们想要转账到目标电子邮件的金额。然后当前用户的金额将转入收款人的账户。
抱歉问的太多了,我还在学习 Firestore 如何为 uni 项目工作。
【问题讨论】:
-
嗨,当前的代码不起作用吗?
print(snapshot.docs[0].data()['user.uid']);打印什么?
标签: flutter google-cloud-firestore