queueHandler method

void queueHandler(
  1. Response handler(
    1. Request request
    ), {
  2. Duration? delay,
})

Enqueues a function that creates a response for the next request.

Adds a dynamic response handler to the response queue. Each request removes the earliest enqueued response before sending it. When handler is encountered in the queue, it is called and the response it returns is sent back to the client.

Optionally includes a delay before sending the response to simulate long-running tasks or network issues.

Implementation

void queueHandler(Response handler(Request request), {Duration? delay}) {
  _responseQueue.add(
      _MockServerResponse(handler: handler, delay: delay ?? defaultDelay));
}