NetworkFilterChain<T> class
Immutable, ordered chain of NetworkFilters with short-circuit evaluation.
The chain runs filters in insertion order and stops at the first false.
An empty chain permits everything (returns true).
Chains are value-like: add and merge return new instances.
Example:
// Build a chain that logs only successful (2xx) GET/POST responses.
final chain = NetworkFilterChain<Response<dynamic>>([
const StatusCodeFilter.successOnly(),
const HttpMethodFilter({'GET', 'POST'}),
]);
if (chain.apply(response)) {
logger.logNetworkResponse(response);
}
// Extend an existing chain:
final sampled = chain.add(const SamplingFilter(0.1));
Constructors
-
NetworkFilterChain(List<
NetworkFilter< filters)T> > -
Creates a chain from an ordered list of filters.
const
- NetworkFilterChain.empty()
-
Creates an empty chain that permits all events.
const
- NetworkFilterChain.fromPredicate(bool predicate(T))
-
Wraps a legacy
bool Function(T)callback as a single-filter chain.factory
Properties
Methods
-
add(
NetworkFilter< T> filter) → NetworkFilterChain<T> -
Returns a new chain with
filterappended. -
apply(
T value) → bool -
Runs all filters in order. Returns
falseon the first failing filter (short-circuit). An empty chain returnstrue. -
merge(
NetworkFilterChain< T> other) → NetworkFilterChain<T> -
Returns a new chain combining this chain's filters with
other's. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
any<
T> (List< NetworkFilter< filters) → NetworkFilter<T> >T> -
Creates an OR-combinator filter: passes if any filter returns
true.