Semih Yilmaz
Semih Yilmaz

Reputation: 618

Flutter Firestore Query with whereIn: List is not working

When querying with where() in Firestore, it succeeds when I give the values one by one, but when I export a list, nothing returns.

Successful sample code:

List temp = example.sharedPreferences.getStringList(example.userList);
Firestore.instance.collection('example').where('id', whereIn: ['77','30','71','13']).snapshots(),

Failed sample code:

List temp = example.sharedPreferences.getStringList(example.userList);
Firestore.instance.collection('example').where('id', whereIn: [temp]).snapshots(),

What can I do in this situation?

Upvotes: 2

Views: 1710

Answers (1)

Peter Haddad
Peter Haddad

Reputation: 80914

temp is already a list therefore in the failed sample code, you don't need to use [], just do the following:

List temp = example.sharedPreferences.getStringList(example.userList);
Firestore.instance.collection('example').where('id', whereIn: temp).snapshots()

Upvotes: 4

Related Questions