[英]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.