ApiSuccess<T> class
final
A successful API response.
Constructors
-
ApiSuccess({required String message, required int statusCode, T? data, Map<
String, dynamic> ? raw}) -
const
Properties
- data → T?
-
Parsed model — null if parsing failed or no data was returned.
final
- dataOrNull → T?
-
Convenience: get data or null.
no setterinherited
- 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 e.g. "Login successful" — use in snackbars.
final
-
raw
→ Map<
String, dynamic> ? -
Full raw response map — available if screen needs extra fields.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- statusCode → int
-
HTTP status code e.g. 200, 201.
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