Flutter Firestore Query with whereIn: List is not working

603

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()
Share:
603
Semih Yılmaz
Author by

Semih Yılmaz

Updated on December 25, 2022

Comments

  • Semih Yılmaz
    Semih Yılmaz over 1 year

    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?

  • Semih Yılmaz
    Semih Yılmaz almost 3 years
    It escaped my attention, it worked. Thanks.