algolia / algoliasearch-helper-flutter

⚡️ Building block to create instant-search applications with Flutter
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/flutter/
Other
22 stars 15 forks source link

calling filterState.set with a groupID clears filters from other groups as well #66

Closed erf closed 10 months ago

erf commented 1 year ago

Describe the bug 🐛

Calling filterState.set with a groupID clears filters from other groups as well.

VladislavFitz commented 10 months ago

Hi @erf,

Thank you for reaching out! As you've noticed and as mentioned in our documentation, the set function is designed to override the existing content of the FilterState with the new Map<FilterGroupID, Set<Filter>> value you provide. This behavior is intentional to allow for a complete reset or replacement of filters.

If your goal is to modify the content of a specific filter group rather than replacing it entirely, I recommend using the add and remove functions. These functions are specifically intended for incremental changes, allowing you to add or remove filters without affecting the existing state of other filters in the group.

Here's a quick example for clarity:

These methods ensure that you can manage the filter state dynamically without losing the existing setup. Let me know if this helps or if you have any more questions!