如何搜索用户数据并使用 flutter 从 firebase 检索它们?

How to search for user data and retrieve them from firebase with flutter?

我正在尝试检索存储在 firebase 数据库中的用户数据,并将其与输入的文本“尝试登录,但使用另一种方式 ;)”进行比较,但是当我搜索示例时,我不太理解他们的方法检索数据他们不检索特定数据而是集合,所以有什么想法吗?

要获取数据,您需要执行以下操作:

  void getUserData() async{
    var firebaseUser = await FirebaseAuth.instance.currentUser();
    firestoreInstance.collection("users").document(firebaseUser.uid).get().then((value){
      print(value.data);
    });
  }

假设您使用 Firebase 身份验证作为文档 ID

您可以使用 firestore 中的“where”功能

FirebaseFirestore.instance
.collection('users')
.where('email', isEqualTo: your_text_controller)
.get()
.then(...);