【发布时间】:2023-01-20 03:23:39
【问题描述】:
我实际上正在开发一个社交应用程序。我想创建一个朋友系统,但我正在为用户搜索而苦苦挣扎。 我希望用户将他朋友的用户名放在 TextField 小部件中,查询 Cloud Firestore (Firebase) 数据库并获取朋友的用户个人资料(如果存在)。
问题是,用户名存储在“Users/USER_ID/profile/username”中,我不知道如何为这个需求查询数据库。
Here is the Cloud Firestore "path" i'm talking about
欢迎提供一点帮助:)
我试过了,但它返回null,可能是因为它没有在正确的地方搜索。
dynamic sUserFromUsername(String username) async {
try {
await FirebaseFirestore.instance
.collection('Users')
.where('username', isEqualTo: username)
.get()
.then((value) => value);
} catch (exception) {
print(exception);
}
}
【问题讨论】:
标签: android flutter dart google-cloud-firestore