LuckyResponse class

Wraps a Dio Response with convenient status helpers and parsing methods.

Every call to Connector.send returns a LuckyResponse. Use the status getters to branch on success or failure, and the parsing helpers to decode the body into a typed value.

Constructors

LuckyResponse(Response raw)
Creates a LuckyResponse that wraps raw.

Properties

data → dynamic
The decoded response body as returned by Dio.
no setter
hashCode → int
The hash code for this object.
no setterinherited
headers → Map<String, List<String>>
The response headers as a map of header names to value lists.
no setter
isClientError → bool
Whether the status code is in the 4xx range (400–499).
no setter
isHtml → bool
Whether the response Content-Type header indicates HTML.
no setter
isJson → bool
Whether the response Content-Type header indicates JSON.
no setter
isRedirect → bool
Whether the status code is in the 3xx range (300–399).
no setter
isServerError → bool
Whether the status code is in the 5xx range (500+).
no setter
isSuccessful → bool
Whether the status code is in the 2xx range (200–299).
no setter
isXml → bool
Whether the response Content-Type header indicates XML.
no setter
raw → Response
The raw Dio response object.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
statusCode → int
The HTTP status code, or 0 if none was received.
no setter
statusMessage → String?
The HTTP status message accompanying statusCode, if any.
no setter

Methods

as<T>(T parser(LuckyResponse)) → T
Passes this to parser and returns the result.
bytes() → List<int>
Casts data to a List<int> (raw bytes) and returns it.
json() → Map<String, dynamic>
Casts data to a Map<String, dynamic> and returns it.
jsonList() → List
Casts data to a List<dynamic> and returns it.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
text() → String
Casts data to a String and returns it.
throw404IfNotFound() → void
Throws a generic Exception if the status code is 404.
throwIfFailed() → void
Throws a generic Exception if the response is not successful.
toString() → String
A string representation of this object.
inherited

Operators

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