ResponseBody class
Handles HTTP response body content with support for various formats.
This class provides methods for sending different types of content including text, JSON, files, streams, and binary data.
Constructors
- ResponseBody(HttpResponse _response, ResponseHeaders _headers)
Properties
Methods
-
download(
File file, {String? name, bool inline = false, String? contentType}) → Future< void> - Sends a file download response.
-
enableCompression(
) → void - Enables response compression (Gzip).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sendBytes(
List< int> bytes, {String contentType = 'application/octet-stream'}) → void - Sends binary data.
-
sendChunked(
String data) → void - Sends a chunked response with manual control over chunks.
-
sendCustom(
{required String content, required ContentType contentType, Map< String, String> ? headers}) → void - Sends a custom response with full control.
-
sendEmpty(
) → void - Sends an empty response (useful for 204 No Content).
-
sendFile(
File file, {String? contentType, String? rangeHeader}) → Future< void> - Sends a file response with proper MIME type detection and Range support.
-
sendHtml(
String html) → void - Sends an HTML response.
-
sendJson(
dynamic data, {String? contentType}) → void - Sends a JSON response.
-
sendJsonPretty(
dynamic data, {int indent = 2}) → void - Sends a JSON response with pretty printing.
-
sendText(
String text) → void - Sends a plain text response.
-
stream<
T> (Stream< T> stream, {String contentType = 'application/octet-stream', Map<String, String> ? headers, List<int> toBytes(T data)?}) → Future<void> - Streams data to the client with optional transformation.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited