ApiResult<T> class
sealed
The result of every API call — success or error. Never throws. Screens pattern-match on this.
T is the parsed model type.
message is the raw server message — use for snackbars.
data is the parsed model — null on error.
error is the error message — null on success.
statusCode is the HTTP status code.
- Implementers
Properties
- dataOrNull → T?
-
Convenience: get data or null.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isError → bool
-
Whether the request failed.
no setter
- isSuccess → bool
-
Whether the request succeeded.
no setter
- message → String
-
Convenience: get message regardless of outcome.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
ifError(
void callback(String error, String message)) → void - Pattern-match helper — only handle error.
-
ifSuccess(
void callback(T? data, String message)) → void - Pattern-match helper — only handle success, ignore error.
-
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()
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited