ApiResponse<T> class

Standardized response wrapper returned by every AutoPilot request.

Available extensions

Constructors

ApiResponse.failure({required String message, int statusCode = 0, dynamic raw, Map<String, dynamic>? errors, String? requestId, Duration? responseTime})
factory
ApiResponse.success({T? data, String message = 'Success', int statusCode = 200, dynamic raw, String? requestId, Duration? responseTime})
factory

Properties

allErrors String

Available on ApiResponse<T>, provided by the ApiResponseX extension

All validation errors as a single readable string.
no setter
data → T?
final
dataOrThrow → T

Available on ApiResponse<T>, provided by the ApiResponseX extension

Returns data or throws if null.
no setter
errors Map<String, dynamic>?
final
hashCode int
The hash code for this object.
no setterinherited
isClientError bool
True if 4xx client error
no setter
isClientError bool

Available on ApiResponse<T>, provided by the ApiResponseX extension

no setter
isForbidden bool

Available on ApiResponse<T>, provided by the ApiResponseX extension

no setter
isNotFound bool

Available on ApiResponse<T>, provided by the ApiResponseX extension

no setter
isServerError bool
True if 5xx server error
no setter
isServerError bool

Available on ApiResponse<T>, provided by the ApiResponseX extension

no setter
isSuccess bool
final
isTimeout bool

Available on ApiResponse<T>, provided by the ApiResponseX extension

no setter
isUnauthorized bool
True if unauthorized
no setter
isUnauthorized bool

Available on ApiResponse<T>, provided by the ApiResponseX extension

no setter
isValidationError bool
True if validation error
no setter
isValidationError bool

Available on ApiResponse<T>, provided by the ApiResponseX extension

no setter
message String
final
raw → dynamic
final
requestId String?
final
responseTime Duration?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int
final
timestamp DateTime
final

Methods

dataOr(T fallback) → T
Safe data access with fallback
dataOr(T fallback) → T

Available on ApiResponse<T>, provided by the ApiResponseX extension

Returns data or fallback.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override
validationError(String field) String?
First validation error for a field
validationError(String field) String?

Available on ApiResponse<T>, provided by the ApiResponseX extension

First validation error for a specific field.

Operators

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