Filtering in dropdowns from multiple collections

Hey everyone!

I'm pretty new to Flutterflow and I'm trying to build an app that requires some fairly complex query logic (at least, it feels complex because I have tried everything I can think of and can't get it working). I have 3 collections: Users, Locations, and Areas.

Multiple Users can have multiple Locations and vice vera. A Location can have multiple Areas but areas only belong to one Location.

I have my first dropdown that will allow a user to select a Location. I query the Locations collection and filter where the user_ids in the Locations collection is equal to the authenticated user ref.

Once they've selected a location, the id of it is stored in an app variable using the On Selected Action.

I have a second dropdown that should allow the user to select an Area but for some reason, I can't find any way to filter the query of Areas so that the options only show ones that belong to the chosen Location.

The app state I store the selected location in is red and the widget state of the dropdown is red.

Hopefully I have provided enough detail. If you need any more information, let me know. Any advice on whether I'm approaching this the right way or any other suggestions would be greatly appreciated.

Thank you

1