About this widget
AFilterState
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
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
orFilterOperator.or
. For more information, see Combining boolean operators.
Examples
Create
The following is an example of creating and setting up aFilterState
with different filters (facets, tags and numerical):
Dart
(author:Shakespeare) AND (_tags:drama) AND (rating:3 TO 5 AND price < 50)
Read
Listen tofilters
stream to get filtering changes:
Dart
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 usingclear
and clearExcept
:
Dart
Fields
Filters groups stream (facet, tag, numeric and hierarchical).
Dart
Methods
add
Adds a list of filters to a group by its
groupID
.Dart
set
Overrides
filters
list with a provided map
.Dart
remove
Removes a list of
filters
from a group by its groupID
.Dart
toggle
Toggles a
filter
in given group by its groupID
.Dart
contains
Checks if a
filter
exists in a group.Dart
addHierarchical
Adds a
HierarchicalFilter
to a group.Dart
removeHierarchical
Removes
HierarchicalFilter
group by its attribute.Dart
clear
Clears provided group IDs.
If none provided, all filters will be cleared.
Dart
clearExcept
Clears all groups except provided group IDs.
Dart
modify
Asynchronously updates
filters
.
Useful to apply multiple consecutive update operations without firing multiple filters events.Dart
dispose
Releases all underlying resources.
Dart