ApiResponse<T> class

Standard API response model.

Constructors

ApiResponse.new({required bool success, T? data, String? error, String? message, int? statusCode})
const
ApiResponse.badRequest(String error)
Creates a bad request response.
factory
ApiResponse.error(String error, [int? statusCode])
Creates an error response.
factory
ApiResponse.forbidden([String? message])
Creates a forbidden response.
factory
ApiResponse.fromJson(Map<String, dynamic> json)
Creates an ApiResponse from JSON.
factory
ApiResponse.notFound([String? message])
Creates a not found response.
factory
ApiResponse.success(T data, [String? message])
Creates a successful response.
factory
ApiResponse.unauthorized([String? message])
Creates an unauthorized response.
factory

Properties

data → T?
final
error String?
final
hashCode int
The hash code for this object.
no setterinherited
message String?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int?
final
success bool
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() String
Converts the response to JSON.
toString() String
A string representation of this object.
inherited

Operators

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