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<
All validation errors as a single readable string.T> , provided by the ApiResponseX extensionno setter - data → T?
-
final
- dataOrThrow → T
-
Available on ApiResponse<
Returns data or throws if null.T> , provided by the ApiResponseX extensionno 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 extensionno setter - isForbidden → bool
-
Available on ApiResponse<
T> , provided by the ApiResponseX extensionno setter - isNotFound → bool
-
Available on ApiResponse<
T> , provided by the ApiResponseX extensionno setter - isServerError → bool
-
True if 5xx server error
no setter
- isServerError → bool
-
Available on ApiResponse<
T> , provided by the ApiResponseX extensionno setter - isSuccess → bool
-
final
- isTimeout → bool
-
Available on ApiResponse<
T> , provided by the ApiResponseX extensionno setter -
True if unauthorized
no setter
-
Available on ApiResponse<
T> , provided by the ApiResponseX extensionno setter - isValidationError → bool
-
True if validation error
no setter
- isValidationError → bool
-
Available on ApiResponse<
T> , provided by the ApiResponseX extensionno 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<
Returns data orT> , provided by the ApiResponseX extensionfallback. -
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<
First validation error for a specific field.T> , provided by the ApiResponseX extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited