【问题标题】:Flutter, cloud fire store query method, where not working properlyFlutter,云火库查询方法,哪里不能正常工作
【发布时间】:2021-01-19 20:49:25
【问题描述】:

我正在尝试在应用程序中创建搜索功能,在该应用程序中我使用他们的查询方法搜索商店(来自 Cloud Firestore 数据库),但我一直得到相同的结果,这是“列表”上的第一个商店。无论我搜索什么。

                  StreamBuilder(
                    builder: (context , snapshot) {
                      if(snapshot.hasError) {
                        return Center(
                          child: Text(snapshot.error.toString()),
                        );
                      }//end if

                      if (snapshot.hasData) {
                        QuerySnapshot querysnapshot =  snapshot.data;
                        List<QueryDocumentSnapshot> documents = querysnapshot.docs;
                        processData(documents);
                        print("here : " + stores[0].name.toString());
                        print("search: " + searchQuery);
                        print("array length: " + stores.length.toString());
                        return Container(
                          child: ListView.builder(
                            itemBuilder: (context , index) {
                              return Center(
                                child: Text(stores[index].name.toString()),
                              );
                            },
                            itemCount: stores.length,
                          ),
                          height: height,
                        );
                      } else {
                        return Container(
                          child: Center(
                            child: Text("Snapshot has no data"),
                          ),
                        );
                      }//end if-else
                    },
                    stream: FirebaseFirestore.instance.collection('Stores').where('name' , isEqualTo: name).snapshots(),
                  )

【问题讨论】:

    标签: android ios flutter dart google-cloud-firestore


    【解决方案1】:

    对不起,我犯了一个愚蠢的错误。我忘了在 where 函数中使用搜索变量而不是名称变量!

    【讨论】:

    • 没有智能错误:),请将您的答案标记为正确,并输入实际的“搜索变量”。
    猜你喜欢
    • 2021-06-30
    • 1970-01-01
    • 2020-06-20
    • 1970-01-01
    • 2015-09-29
    • 1970-01-01
    • 2020-05-18
    • 2020-02-15
    • 2016-08-01
    相关资源
    最近更新 更多