Filter class

The Filter class is used to construct OData $filter expressions programmatically. It provides methods to create filters like eq (equals), ne (not equals), gt (greater than), lt (less than), and allows combining filters using logical AND/OR.

Example:

final filter = Filter.and(
  Filter.eq('Name', 'Milk'),
  Filter.lt('Price', 2.55),
);

print(filter.toString());
Output: "Name eq 'Milk' and Price lt 2.55"

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Converts the filter to a string for query usage.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

and(Filter left, Filter right) Filter
Combines two filters using a logical AND (e.g., "Name eq 'Milk' and Price lt 2.55").
eq(String field, dynamic value) Filter
Creates an equality filter (e.g., "Name eq 'Milk'").
ge(String field, dynamic value) Filter
Creates a greater-than or equal-to filter.
gt(String field, dynamic value) Filter
Creates a greater-than filter (e.g., "Price gt 2.55").
le(String field, dynamic value) Filter
Creates a less-than or equal-to filter.
lt(String field, dynamic value) Filter
Creates a less-than filter (e.g., "Price lt 2.55").
ne(String field, dynamic value) Filter
Creates a non-equality filter (e.g., "Name ne 'Milk'").
or(Filter left, Filter right) Filter
Combines two filters using a logical OR (e.g., "Name eq 'Milk' or Price lt 2.55").