CkResponse<T> class

A generic typed response wrapper returned by CkTransport.request.

Wraps both success and failure states, giving you data, isSuccess, message, and the optional meta block in a single object.

Example:

final res = await CkTransport.request<User>(
  input: RequestInput(endpoint: '/me', method: RequestMethod.GET),
  responseBuilder: (json) => User.fromJson(json),
);
if (res.isSuccess) {
  print(res.data?.name);
} else {
  print(res.message);
}

Constructors

CkResponse({required T data, required int? statusCode, required bool isSuccess, dynamic raw, bool isRequesting = false, String? message, dynamic meta, CancelToken? cancelToken})

Properties

cancelToken CancelToken?
A CancelToken that can be used to abort the in-flight request.
final
data → T
The parsed response data. May be null on failure.
final
hashCode int
The hash code for this object.
no setterinherited
isRequesting bool
Whether this response is currently awaiting a network response.
final
isSuccess bool
true when the server returned a successful status.
final
message String?
Human-readable message from the server (e.g. validation error text).
final
meta → dynamic
Optional API meta block (dynamic). null when not returned.
final
raw → dynamic
Full decoded HTTP body before CkResponseExtractor data extraction.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int?
HTTP status code returned by the server, e.g. 200, 401, 500.
final

Methods

copyWith({T? data, bool? isSuccess, bool? isRequesting, String? error, dynamic meta, dynamic raw, CancelToken? cancelToken, int? responseCode}) CkResponse<T>
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