extract<T> method

Future<T> extract<T>(
  1. FromRequestParts<T> extractor
)

Runs extractor against this request.

The escape hatch for anything without a method here, which is every custom extractor. Unlike the rest, what it produces is not written at the call site, so annotate the variable — otherwise the reader has to open the extractor to learn what they are holding:

final user = await request.extract<AuthUser>(const TodosWrite());

Leave it unassigned only when the extractor is a pure guard and its value is genuinely unwanted:

await request.extract(const TodosWrite());

An authenticating extractor that returns a caller is rarely a pure guard: checking that someone is signed in without checking who is half a check.

Implementation

Future<T> extract<T>(FromRequestParts<T> extractor) =>
    extractor.require(this);