ApiResponse class

Represents a structured response from an API request, including status code, message, body, and error information.

Constructors

ApiResponse({required int? code, required String? message, dynamic body, List? errors})
Creates an instance of ApiResponse.
ApiResponse.fromJson(Map<String, dynamic> json)
Initializes an ApiResponse instance from a JSON map.
ApiResponse.fromResponse(Response response)
Factory method to create an ApiResponse from an HTTP response object.
factory

Properties

allGood bool
Checks if the API response indicates that everything is good.
no setter
body ↔ dynamic
Dynamic body content of the API response.
getter/setter pair
code int?
HTTP status code of the API response.
getter/setter pair
data List
Getter for accessing the data part of the response body.
no setter
errors List?
List of errors returned by the API, if any.
getter/setter pair
exception String?
Exception message placeholder, currently not in use.
getter/setter pair
hasException String
Retrieves the exception message from the API response.
no setter
hashCode int
The hash code for this object.
no setterinherited
message String?
Message for the API response.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

hasData() bool
Checks if the API response contains any data.
hasError() bool
Checks if there are any errors in the API response.
hasMessageError() bool
Checks if there are any message errors in the API response.
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