mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-07-08 01:30:28 +08:00
Update
This commit is contained in:
@@ -19,4 +19,18 @@ class ApiResult<T> {
|
||||
final String? error;
|
||||
Map<String, dynamic> toJson(Object? Function(T) toJsonT) =>
|
||||
_$ApiResultToJson(this, toJsonT);
|
||||
T unwrap() {
|
||||
if (ok) {
|
||||
return data!;
|
||||
} else {
|
||||
return throw error!;
|
||||
}
|
||||
}
|
||||
(int, String) unwrapErr() {
|
||||
if (ok) {
|
||||
return throw 'unwrap_err called on ok ApiResult';
|
||||
} else {
|
||||
return (status, error!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user