ServerResponse class final
Platform-neutral outgoing response with streaming body support.
Constructors
-
ServerResponse({int status = 200, String? reason, Headers? headers, Stream<
List< ? body})int> > - Creates a streaming response.
-
ServerResponse.bytes(List<
int> bytes, {int status = 200, String? contentType, Headers? headers}) -
Creates a response from buffered bytes.
factory
- ServerResponse.html(String html, {int status = 200, Headers? headers})
-
Creates an HTML response.
factory
- ServerResponse.json(Object? value, {int status = 200, Headers? headers})
-
Creates a JSON response.
factory
- ServerResponse.redirect(Uri location, {int status = 302})
-
Creates a redirect response.
factory
- ServerResponse.text(String text, {int status = 200, String contentType = 'text/plain; charset=utf-8', Headers? headers})
-
Creates a plain-text response.
factory
Properties
-
body
→ Stream<
List< int> > -
The response body chunks.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- headers → Headers
-
The response headers.
final
- reason → String?
-
The optional HTTP reason phrase.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → int
-
The HTTP status code.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readBytes(
) → Future< Uint8List> - Reads and buffers the complete response body.
-
readText(
[Encoding encoding = utf8]) → Future< String> - Reads the complete response body as text.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited