Skip to main content

About this widget

A FilterState holds one or several filters, organized in groups, and emits changes of added or removed filters, which are applied to searches performed by connected components. You can add three types of filters:
  • FilterFacet
  • FilterNumeric
  • FilterTag
A group of filters must be identified by a FilterGroupID. A FilterGroupID has:
  • An optional name
  • A FilterOperator indicating which type of boolean operator should be applied between each filter in the group: FilterOperator.and or FilterOperator.or. For more information, see Combining boolean operators.

Examples

Create

The following is an example of creating and setting up a FilterState with different filters (facets, tags and numerical):
Dart
The preceding code snippet corresponds to the following expression: (author:Shakespeare) AND (_tags:drama) AND (rating:3 TO 5 AND price < 50)

Read

Listen to filters stream to get filtering changes:
Dart
Use snapshot to get the latest Filters value submitted by filters stream:
Dart

Update

FilterState can be updated using methods such as add, set and remove, each modification triggers a filters submission. Use modify to run multiple modifications (atomically), and trigger a single filters submission:
Dart

Delete

Remove all or some filter groups using clear and clearExcept:
Dart

Fields

Stream<Filters>
Filters groups stream (facet, tag, numeric and hierarchical).
Dart

Methods

Adds a list of filters to a group by its groupID.
Dart
Overrides filters list with a provided map.
Dart
Removes a list of filters from a group by its groupID.
Dart
Toggles a filter in given group by its groupID.
Dart
Checks if a filter exists in a group.
Dart
Adds a HierarchicalFilter to a group.
Dart
Removes HierarchicalFilter group by its attribute.
Dart
Clears provided group IDs. If none provided, all filters will be cleared.
Dart
Clears all groups except provided group IDs.
Dart
Asynchronously updates filters. Useful to apply multiple consecutive update operations without firing multiple filters events.
Dart
Gets the latest Filters value submitted by filters:
Dart
Releases all underlying resources.
Dart
Last modified on July 22, 2026