redirectNextUri method

Future<String> redirectNextUri(
  1. Uri uri, {
  2. int status = HttpStatus.movedTemporarily,
  3. bool checkApiPath = true,
})

Redirects the response to the given URI and waits for the redirect to complete.

Sets the HTTP status code for the redirect and performs the redirection. This method closes the response and waits for the redirection to complete.

uri - The URI to redirect to. status - The HTTP status code to be used for the redirection. Default is 302 (moved temporarily). checkApiPath - A flag indicating whether to prefix the path with /api if it's an API endpoint. Default is true.

Returns a Future<String> with a message indicating the redirection status.

Implementation

Future<String> redirectNextUri(
  Uri uri, {
  int status = HttpStatus.movedTemporarily,
  bool checkApiPath = true,
}) async {
  if (isClosed) {
    return '';
  }
  isClosed = true;
  await response.redirect(
    uri,
    status: status,
  );
  return "Wait to redirect!?";
}