handle method Null safety

  1. @override
FutureOr<RequestOrResponse> handle(
  1. Request request

The primary request handling method of this object.

Subclasses implement this method to provide their request handling logic.

If this method returns a Response, it will be sent as the response for request linked controllers will not handle it.

If this method returns request, the linked controller handles the request.

If this method returns null, request is not passed to any other controller and is not responded to. You must respond to request through Request.raw.


FutureOr<RequestOrResponse> handle(Request request) async {
  this.request = request;

  var preprocessedResult = await willProcessRequest(request);
  if (preprocessedResult is Request) {
    return _process();
  } else if (preprocessedResult is Response) {
    return preprocessedResult;

  throw StateError(
      "'$runtimeType' returned invalid object from 'willProcessRequest'. Must return 'Request' or 'Response'.");