ApiError<T> class final

A failed API response.

Inheritance

Constructors

ApiError({required String message, required String error, int? statusCode, Map<String, dynamic>? raw})
const

Properties

dataOrNull → T?
Convenience: get data or null.
no setterinherited
error String
Error detail — logged as warning, shown if needed.
final
hashCode int
The hash code for this object.
no setterinherited
isError bool
Whether the request failed.
no setterinherited
isSuccess bool
Whether the request succeeded.
no setterinherited
message String
Server message if available, otherwise a generic fallback.
final
raw Map<String, dynamic>?
Full raw error response map if the server returned one.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int?
HTTP status code — null if request never reached the server.
final

Methods

ifError(void callback(String error, String message)) → void
Pattern-match helper — only handle error.
inherited
ifSuccess(void callback(T? data, String message)) → void
Pattern-match helper — only handle success, ignore error.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
when<R>({required R success(T? data, String message, int statusCode), required R error(String error, String message, int? statusCode)}) → R
Pattern-match helper — mirrors Riverpod's AsyncValue.when()
inherited

Operators

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