ReadResult<T> class sealed

////////////// READ RESULTS ////////////// Outcome of an attempted read operation. It may have succeeded, failed, or had no chance due to connectivity issues.

Available extensions
Annotations
  • @Freezed.new()

Constructors

ReadResult.failure(FailureReason reason, String message)
Represents a failure with the write, resulting from either an unexpected problem on the server or the server rejecting the client's request. The message property should be suitable for showing the user.
const
factory
ReadResult.fromApiError(ApiError e)
Builder for a failed write attemped, derived from its ApiError.
factory
ReadResult.success(T? item, {required RequestDetails details})
Container for the results of a single object read that did not encounter any errors. Note that the requested object may be null, which is not an error.
const
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

errorOrRaise() → ReadFailure<T>
Helper to extract expected ReadFailure objects or throw in the case of an unexpected ReadSuccess.
getOrRaise() → ReadSuccess<T>
Helper to extract expected ReadSuccess objects or throw in the case of an unexpected ReadFailure.
itemOrRaise() → T?
Helper to extract expected T? objects or throw in the case of an unexpected ReadFailure.
map<TResult extends Object?>({required TResult success(ReadSuccess<T> value), required TResult failure(ReadFailure<T> value)}) → TResult

Available on ReadResult<T>, provided by the ReadResultPatterns extension

A switch-like method, using callbacks.
mapOrNull<TResult extends Object?>({TResult? success(ReadSuccess<T> value)?, TResult? failure(ReadFailure<T> value)?}) → TResult?

Available on ReadResult<T>, provided by the ReadResultPatterns extension

A variant of map that fallback to returning null.
maybeMap<TResult extends Object?>({TResult success(ReadSuccess<T> value)?, TResult failure(ReadFailure<T> value)?, required TResult orElse()}) → TResult

Available on ReadResult<T>, provided by the ReadResultPatterns extension

A variant of map that fallback to returning orElse.
maybeWhen<TResult extends Object?>({TResult success(T? item, RequestDetails details)?, TResult failure(FailureReason reason, String message)?, required TResult orElse()}) → TResult

Available on ReadResult<T>, provided by the ReadResultPatterns extension

A variant of when that fallback to an orElse callback.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
when<TResult extends Object?>({required TResult success(T? item, RequestDetails details), required TResult failure(FailureReason reason, String message)}) → TResult

Available on ReadResult<T>, provided by the ReadResultPatterns extension

A switch-like method, using callbacks.
whenOrNull<TResult extends Object?>({TResult? success(T? item, RequestDetails details)?, TResult? failure(FailureReason reason, String message)?}) → TResult?

Available on ReadResult<T>, provided by the ReadResultPatterns extension

A variant of when that fallback to returning null

Operators

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