【发布时间】: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