Response.movedPermanently constructor

Response.movedPermanently(
  1. Object location, {
  2. Object? body,
  3. Map<String, Object>? headers,
  4. Encoding? encoding,
  5. Map<String, Object>? context,
})

Constructs a 301 Moved Permanently response.

This indicates that the requested resource has moved permanently to a new URI. location is that URI; it can be either a String or a Uri. It's automatically set as the Location header in headers.

body is the response body. It may be either a String, a List<int>, a Stream<List<int>>, or null to indicate no body.

If the body is a String, encoding is used to encode it to a Stream<List<int>>. It defaults to UTF-8. If it's a String, a List<int>, or null, the Content-Length header is set automatically unless a Transfer-Encoding header is set. Otherwise, it's a Stream<List<int>> and no Transfer-Encoding header is set, the adapter will set the Transfer-Encoding header to "chunked" and apply the chunked encoding to the body.

If encoding is passed, the "encoding" field of the Content-Type header in headers will be set appropriately. If there is no existing Content-Type header, it will be set to "application/octet-stream". headers must contain values that are either String or List<String>. An empty list will cause the header to be omitted.

Implementation

Response.movedPermanently(
  Object location, {
  Object? body,
  Map<String, /* String | List<String> */ Object>? headers,
  Encoding? encoding,
  Map<String, Object>? context,
}) : this._redirect(301, location, body, headers, encoding, context: context);