1

I have a Firestore collection I am querying and referencing another document that I have already queried prior (teamRecord). In this case everything is working up to the final 'user_inchallenge' call. In this case, the user_inchallenge is a DocumentReference and the teamRecord.usersInTeam is a List of DocumentReferences. However, there whereIn call does not seem to be working properly. I only want to return docs where user_inchallenge is held within teamRecord.usersInTeam.

FirebaseFirestore
.instance
.collection('activity_units')
.orderBy('activity_value', descending: true)
.where('challenge_reference', isEqualTo: challenges.reference)
//below is not working
.where('user_inchallenge', whereIn: teamRecord.usersInTeam.asList())

As a note, if I remove the .asList() call in usersInTeam I get the error:

The argument type 'BuiltList<DocumentReference>' can't be assigned to the parameter type 'List'.

I also tried isEqualTo, arrayContains, but none of them have returns the filtered results.

1 Answer 1

0

The whereIn parameter expects a List, and it seems that BuiltList is not actually a List.

You'll want to convert your BuiltList to a List (e.g. by calling asList() or toList() on it) and then pass that to the Firestore call.

I filed issue #10407 on the GitHub repo to see if the types can be change to be Iterable.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you! I think that would be a good edit for the types.
No matter what changes you make, even if you transform the data into a static format like ['AAA', 'BBB'], it won't yield any results because "wherein" is not functioning. This new feature is still incomplete and has serious bugs.
@Kevin I've successfully used whereIn in multiple Flutter projects. If you're having a hard time making it work, I recommend posting a new question for it with your own minimal repro so we can check what's going on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.