ApiResponse class

API response

Constructors

ApiResponse({required int statusCode, dynamic data, Map<String, String> headers = const {}})
ApiResponse.badRequest([String? message])
Bad request response (400)
factory
ApiResponse.created([dynamic data])
Created response (201)
factory
ApiResponse.error([String? message])
Internal server error response (500)
factory
ApiResponse.forbidden([String? message])
Forbidden response (403)
factory
ApiResponse.json(dynamic data, {int statusCode = 200})
Success response with JSON data
factory
ApiResponse.methodNotAllowed()
Method not allowed response (405)
factory
ApiResponse.noContent()
No content response (204)
factory
ApiResponse.notFound([String? message])
Not found response (404)
factory
ApiResponse.ok([dynamic data])
Success response
factory
ApiResponse.redirect(String location, {bool permanent = false})
Redirect response
factory
ApiResponse.unauthorized([String? message])
Unauthorized response (401)
factory

Properties

data → dynamic
final
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int
final

Methods

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

Operators

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