PageRedirect class final

Response indicating a redirect to another URL.

Use this to redirect users to a different page, for example after authentication or when a resource has moved.

Usage

// Basic redirect (302 Found)
return PageRedirect('/login');

// Permanent redirect (301)
return PageRedirect.permanent('/new-location');

// Temporary redirect (307)
return PageRedirect.temporary('/maintenance');

// With custom status code
return PageRedirect('/other', statusCode: 303);
Inheritance

Constructors

PageRedirect(String location, {int statusCode = 302, Map<String, String> headers = const {}, List<Cookie> cookies = const []})
Creates a redirect response to the given location.
const
PageRedirect.permanent(String location, {List<Cookie> cookies = const []})
Creates a permanent redirect (301 Moved Permanently).
const
PageRedirect.seeOther(String location, {List<Cookie> cookies = const []})
Creates a "See Other" redirect (303 See Other).
const
PageRedirect.temporary(String location, {List<Cookie> cookies = const []})
Creates a temporary redirect (307 Temporary Redirect).
const

Properties

cookies List<Cookie>
Creates a redirect response to the given location.
final
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
Additional HTTP headers for the response.
final
location String
The URL to redirect to.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int
HTTP status code for the redirect.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited