gpt4 book ai didi

android - flutter ,云火存储查询方法,其中无法正常工作

转载 作者:行者123 更新时间:2023-12-03 04:35:19 24 4
gpt4 key购买 nike

我正在尝试在一个应用程序中使用搜索功能,在该应用程序中我使用他们的查询方法(从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(),
)

最佳答案

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

关于android - flutter ,云火存储查询方法,其中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64200972/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com