I'm creating todo list in which I'll have two lists one for incomplete tasks and another for completed tasks...I'm able to retrieve the data from Firestore by pulling the whole data without any condition, but for the uncompleted list, I want to retrieve the document only with particular field values. For example, each document contains the following fields as shown in the picture:
下面是我用来从Firebase FireStore获取数据的代码:
static List<Task> getTasks() {
//convert firebase collection to list
List<Task> tasks = [];
FirebaseFirestore.instance.collection('Todos').snapshots().listen((data) {
data.docs.forEach((doc) {
tasks.add(Task.fromMap(doc.data()));
});
});
return tasks;
}
我希望类似这样的函数只检索taskStatus==True的文档.因此,我可以将taskStatus为True的所有任务存储在单独的列表中,并相应地显示它们.