extract method
Produces the value, or the rejection that stops the handler.
Implementation
@override
Future<Result<T, Rejection>> extract(Request request) async {
final value = request.context[stateKeyFor<T>()];
if (value == null) {
return Err(
Rejection.internal(
'no $T state is attached; add withState<$T>(...) where the routes '
'are mounted',
),
);
}
if (value is! T) {
return Err(
Rejection.internal('the attached $T state has the wrong type'));
}
return Ok(value);
}