CindelFilter builder for constructing predicates dynamically at runtime. Use generated helpers for everyday application code; reach for CindelFilter when filter logic must be assembled from runtime data.
Generated Filters
Generated filters start from a typed collection’s.filter() builder. Every helper is derived from a persisted model field — named after it, typed to it, and aware of any custom conversions applied to it.
CindelFilter — Dynamic Filters
CindelFilter builds predicates from persisted field names, making it suitable for scenarios where the field or condition is only known at runtime. Apply a dynamic predicate to a query with whereMatches(...).
@Name, the persisted field name may differ from the Dart field name. Pass the persisted name to CindelFilter.field(...). Generated helpers avoid this issue entirely.
Field Predicates
The following predicates are available onCindelFilter.field(...) (and have generated equivalents for each persisted model field):
Examples using
CindelFilter:
Embedded Object Paths
Generated Embedded Filters
When data is stored inside embedded objects, the generated API exposes nested filter callbacks that traverse the embedded structure in a type-safe way:Dynamic Paths with CindelFilter.path
Use CindelFilter.path([...]) when an embedded field path must be assembled at runtime. Provide the path as a list of persisted field name segments.
CindelFilter.path(...) only when the path cannot be determined at compile time. For known paths, the generated nested filter callbacks are safer and more readable.
Boolean Composition
Compose multipleCindelFilter predicates with all, any, and not.
CindelFilter.all — AND
Every predicate in the list must match:
CindelFilter.any — OR
At least one predicate in the list must match:
CindelFilter.not — Negation
Invert a predicate:
Composition with Generated Helpers
When the field helpers are known at compile time, theanyOf and allOf query modifiers are often more readable than manual CindelFilter composition:
CindelFilter boolean composition when you need to build a predicate tree directly — for example, when the structure itself is determined at runtime.
Choosing the Right Approach
- Generated filters (preferred)
- CindelFilter (dynamic)
Use generated filters for all normal application code. They are compile-time checked, follow your Dart model names, and apply conversions automatically.Combine
where() for indexed lookups with filter() for additional conditions: