Flutter Firebase 过滤器数组ContainsAny

use*_*910 0 flutter google-cloud-firestore

我有一个动态填充的字符串列表(最多 5 个项目)。现在我想根据这些项目从 firsestore 过滤我的文档,所以我写了这样的:

List<String> lst= new List();
lst.add('A');
lst.add('B');
lst.add('C');
    Query collectionRef = Firestore.instance
        .collection("files")
        .document(Userpref.language)
        .collection("files")
        .where("describeFear", arrayContainsAny: [
       lst
    ]);
Run Code Online (Sandbox Code Playgroud)

在 [] 内,如果我输入列表名称,它将不起作用。另外,如果我将列表中的所有项目放入变量中并将其传递给 [] ,它将不起作用。

它唯一起作用的时候是当我输入像“A”、“B”、“C”这样的值时。这是可行的,但我需要传递数组,因为它是动态的。有人可以帮忙吗?

Sat*_*ddy 5

对于此用例,您需要使用 whereIn 而不是 arrayContainsAny

List<String> lst= new List();
lst.add('A');
lst.add('B');
lst.add('C');

Query collectionRef = Firestore.instance
    .collection("files")
    .document(Userpref.language)
    .collection("files")
    .where("describeFear", whereIn: [
   lst
]);
Run Code Online (Sandbox Code Playgroud)