[英]Is there a way in using firestore that will print a message using flutter if an array contains a string
如果数组包含字符串,是否有一种使用 firestore 的方法将使用 flutter 打印消息。
我想检查特定文档中的数组是否包含用户 email。 如果数组包含用户 email,它将显示一条消息。
这是我当前的代码,但它不起作用。
(FirebaseFirestore.instance.collection('users').where(
'requests',
arrayContains: user.email) == true)
? Text("true")
: Text("false");
从 firestore 获取用户电子邮件列表并存储在本地列表 [listName] 中。 然后调用 listName.contains(userEmail) 并将结果存储在 bool 变量中。 像这样,
bool isEmailexist = usersList.contains(userEmail);
最后,您可以通过检查 bool 值来显示您的消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.