Response.redirect constructor

Response.redirect(
  1. String url, [
  2. int status = 307
])

Implementation

factory Response.redirect(String url, [int status = 307]) {
  assert(
    status == 301 ||
        status == 302 ||
        status == 303 ||
        status == 307 ||
        status == 308,
    'Invalid redirect status code, must be 301, 302, 303, 307 or 308',
  );

  return Response._(
    Stream.empty(),
    status: status,
    statusText: status.httpReasonPhrase,
    headers: {'Location': url},
  );
}